[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: handle TapdiskException when xm block-attach failed



Maybe we should check the vhd file is exist or not:
From: Yi Li <peteryili@xxxxxxxxxxx>
Date: Thu, 20 Mar 2014 17:15:00 +0800
Subject: [PATCH] xen: check the vhd file exist using block-attach

Signed-off-by: Yi Li <peteryili@xxxxxxxxxxx>

diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
index 5ed781c..1416db9 100644
--- a/tools/python/xen/xm/main.py
+++ b/tools/python/xen/xm/main.py
@@ -2650,6 +2650,19 @@ def parse_block_configuration(args):
Âdef xm_block_attach(args):
ÂÂÂÂ arg_check(args, 'block-attach', 4, 5)
Â
+ÂÂÂ #check back_dev and front_dev, by tlinux_xen team
+ÂÂÂ uname=args[1]
+ÂÂÂ uname_list=uname.split(":")
+ÂÂÂ back_dev=uname_list[len(uname_list)-1]
+ÂÂÂ front_dev=args[2] if ("/dev" in args[2]) else ("/dev/" + args[2])
+ÂÂÂ if not os.path.exists(back_dev):
+ÂÂÂÂÂÂÂ print "Error: %s not exist " % back_dev
+ÂÂÂÂÂÂÂ sys.exit(1)
+
+ÂÂÂ if os.path.exists(front_dev):
+ÂÂÂÂÂÂÂ print "Error: %s already exists " % front_dev
+ÂÂÂÂÂÂÂ sys.exit(1)
+
ÂÂÂÂ if serverType == SERVER_XEN_API:
ÂÂÂÂÂÂÂÂ domÂÂ = args[0]
ÂÂÂÂÂÂÂÂ uname = args[1]
--
1.7.1


2014-03-20 9:47 GMT+08:00 æä <yilikernel@xxxxxxxxx>:
Hi ALL,

[How to preduce]

On dom0: (b.vhd is exist,but a.vhd is not exist)

1: xm block-attach 0 tap2:tapdisk:vhd:/root/a.vhd /dev/xvdz w

Error: ('create', '-avhd:/root/a.vhd') failed (512Â )
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]
Create a new virtual block device.

2: xm block-attach 0 tap2:tapdisk:vhd:/root/b.vhd /dev/xvdz w

it will report that
"
Error: The device "/dev/xvdz" is already defined
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]

Create a new virtual block device.
"

[Expected Result]

the step 2 should be success.





Thanks
YiLi


2014-03-20 9:25 GMT+08:00 æä <yilikernel@xxxxxxxxx>:

From 7a4b67d235569d81307095ad1366bc03bae5b812 Mon Sep 17 00:00:00 2001
From: Yi Li <peteryili@xxxxxxxxxxx>
Date: Thu, 20 Mar 2014 09:15:45 +0800
Subject: [PATCH] xen: handle TapdiskException when xm block-attach failed

Maybe we should handle the TapdiskException for the command below
'xm block-attach 0 tap2:tapdisk:vhd:/root/a.vhd /dev/xvdz w'
or /dev/xvdz said it is already defined.

Signed-off-by: Yi Li <peteryili@xxxxxxxxxxx>
---
Âtools/python/xen/xend/XendDomainInfo.py |ÂÂÂ 4 ++--
Â1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 8d4ff5c..2270ab1 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -65,7 +65,7 @@ from xen.xend.XendConstants import *
Âfrom xen.xend.XendAPIConstants import *
Âfrom xen.xend.XendCPUPool import XendCPUPool
Âfrom xen.xend.server.DevConstants import xenbusState
-from xen.xend.server.BlktapController import TapdiskController
+from xen.xend.server.BlktapController import TapdiskController, TapdiskException

Âfrom xen.xend.XendVMMetrics import XendVMMetrics

@@ -861,7 +861,7 @@ class XendDomainInfo:
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ # blktap1
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ dev_type = self.getBlockDeviceClass(devid)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ self._waitForDevice(dev_type, devid)
-ÂÂÂÂÂÂÂÂÂÂÂ except VmError, ex:
+ÂÂÂÂÂÂÂÂÂÂÂ except (VmError, TapdiskException), ex:
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ del self.info['devices'][dev_uuid]
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if dev_type == 'pci':
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ for dev in dev_config_dict['devs']:
--
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.