Skip to contentSkip to conversation

Add blktap disk type check

PATCH In review Masaki Kanno 1 participant 2 messages Aug 21, 2007 – Aug 31, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add blktap disk type check

Hi,

This patch adds a check of disk type for blktap. You get the following error messages by the patch when you give a wrong disk type to xm commands.

# xm create /xen/vm1.conf disk='tap:xxx:/xen/root-vm1.img,hda1,w'
Using config file "/xen/vm1.conf".
Error: tap:xxx not a valid disk type
# xm block-attach vm2 tap:yyy:/xen/second.img hdb1 w
Error: tap:yyy not a valid disk type
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]

Create a new virtual block device.

Best regards,
Kan

tools/python/xen/xend/XendConfig.py +6 -0
diff -r 256160ff19b7 tools/python/xen/xend/XendConfig.py
@@ -28,6 +28,7 @@ from xen.xend.XendDevices import XendDev
 from xen.xend.XendDevices import XendDevices
 from xen.xend.PrettyPrint import prettyprintstring
 from xen.xend.XendConstants import DOM_STATE_HALTED
+from xen.xend.server.BlktapController import blktap_disk_types
 from xen.xend.server.netif import randomMAC
 from xen.util.blkif import blkdev_name_to_number
 from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
@@ -1084,6 +1085,11 @@ class XendConfig(dict):
                 else:
                     dev_info['driver'] = 'paravirtualised'
 
+            if dev_type == 'tap':
+                if dev_info['uname'].split(':')[1] not in blktap_disk_types:
+                    raise XendConfigError("tap:%s not a valid disk type" %
+                                    dev_info['uname'].split(':')[1])
+
             if dev_type == 'vif':
                 if not dev_info.get('mac'):
                     dev_info['mac'] = randomMAC()
tools/python/xen/xend/server/BlktapController.py +8 -0
diff -r 256160ff19b7 tools/python/xen/xend/server/BlktapController.py
@@ -6,6 +6,14 @@ from xen.xend.XendLogging import log
 
 phantomDev = 0;
 phantomId = 0;
+
+blktap_disk_types = [
+    'aio',
+    'sync',
+    'vmdk',
+    'ram',
+    'qcow'
+    ]
 
 class BlktapController(BlkifController):
     def __init__(self, vm):

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hi,

Could you apply this patch?

If without the patch, a wrong blktap disk is attached to a guest domain. But the state of the wrong blktap disk remains "3", it does not become "4". If the wrong blktap disk is root image for the guest domain, the guest kernel shows the following messages, and does a panic. I'd like to point out a disk type error of the blktap disk by the patch for users.

# xm create /xen/vm1.conf disk='tap:xxx:/xen/root-vm1.img,hda1,w'
Using config file "/xen/vm1.conf".
Started domain vm1
# xm block-list vm1
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     3      6      8     /local/domain/0/backend/tap/4/769  

XENBUS: Waiting for devices to initialise: 295s...290s...285s...280s... 275s...270s...265s...260s...255s...250s...245s...240s...235s...230s... 225s...220s...215s...210s...205s...200s...195s...190s...185s...180s... 175s...170s...165s...160s...155s...150s...145s...140s...135s...130s... 125s...120s...115s...110s...105s...100s...95s...90s...85s...80s...75s... 70s...65s...60s...55s...50s...45s...40s...35s...30s...25s...20s...15s... 10s...5s...0s...
XENBUS: Timeout connecting to device: device/vbd/769 (local state 3, remote state 2)
XENBUS: Device with no driver: device/console/0
BIOS EDD facility v0.16 2004-Jun-25, 0 devices found
EDD information not available.
Freeing unused kernel memory: 196k freed
usbcore: no version for "struct_module" found: kernel tainted.
usbcore: registered new driver usbfs
usbcore: registered new driver hub
USB Universal Host Controller Interface driver v3.0
SCSI subsystem initialized
Adaptec aacraid driver (1.1-5[2409]-mh2)

Kernel panic - not syncing: Attempted to kill init!

Best regards,
Kan

Quoted 28 lines · Masaki Kanno

Hi,

This patch adds a check of disk type for blktap. You get the following error messages by the patch when you give a wrong disk type to xm commands.

# xm create /xen/vm1.conf disk='tap:xxx:/xen/root-vm1.img,hda1,w'
Using config file "/xen/vm1.conf".
Error: tap:xxx not a valid disk type
# xm block-attach vm2 tap:yyy:/xen/second.img hdb1 w
Error: tap:yyy not a valid disk type
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]

Create a new virtual block device.

Best regards,
Kan

-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel