Skip to contentSkip to conversation

Allow blktap to be able to be booted as system volume for PV-on-HVM

PATCH In review Kasai Takanori 2 participants 5 messages Jul 6, 2007 – Jul 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow blktap to be able to be booted as system volume for PV-on-HVM

Hi All,

We were testing the PV driver on the HVM domain.
When blktap was booting system volume, PV-on-HVM domain was not able to be started.

The configuration file is specified as follows. disk = [ 'tap:aio:/xen/test/rhel5ga_full.img,hda,w' ]

The error occurred by the initialization of system volume in qemu-dm.

qemu: could not open hard disk image 'aio:/xen/test/rhel5ga_full.img'

It is because "aio:" is added to the head of params in xenstore. However, qemu-dm open device by params.

This patch corrected the problem of params on the qemu-dm.

The execution result is as follows.

# xm create -f rhel5ga_vti.conf
Using config file "./rhel5ga_vti.conf".
Started domain RHEL5GA-test2
# xm block-list RHEL5GA-test2
Vdev  BE handle state evt-ch ring-ref BE-path
768    0    0     1      -1     -1    /local/domain/0/backend/tap/75/768
...      <<= /* Waiting for booting process */
# xm block-list RHEL5GA-test2
Vdev  BE handle state evt-ch ring-ref BE-path
768    0    0     4      7      8     /local/domain/0/backend/tap/75/768

Best Regards,

--
Takanori Kasai

# HG changeset patch
# User [email protected]
# Date 1183713661 -32400
# Node ID 9d9d64fae3cd39cc7dbd398dd94ead6e413980bd
# Parent d54d47fc8c6cdea23437476407bec05d85742760
Allow blktap to be able to be booted as system volume for PV-on-HVM

tools/ioemu/xenstore.c +9 -2
diff -r d54d47fc8c6c -r 9d9d64fae3cd tools/ioemu/xenstore.c
@@ -173,10 +173,17 @@ void xenstore_parse_domain_config(int do
         }
         /* open device now if media present */
         if (params[0]) {
+            char *p = NULL;
+            if ((p = strchr(params, ':'))) {
+                p++;
+            }
+            else {
+                p = params;
+            }
             if (bdrv_open(bs_table[hd_index + (is_scsi ? MAX_DISKS : 0)],
-                          params, 0 /* snapshot */) < 0)
+                          p, 0 /* snapshot */) < 0)
                 fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
-                        params);
+                        p);
         }
     }
 

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

#1 lore raw
Quoted 9 lines · Kasai Takanori

Hi All,

We were testing the PV driver on the HVM domain.
When blktap was booting system volume, PV-on-HVM domain was not able to be started.

The configuration file is specified as follows. disk = [ 'tap:aio:/xen/test/rhel5ga_full.img,hda,w' ]

Quoted 8 lines

The error occurred by the initialization of system volume in qemu-dm.

qemu: could not open hard disk image 'aio:/xen/test/rhel5ga_full.img'

It is because "aio:" is added to the head of params in xenstore. However, qemu-dm open device by params.

This patch corrected the problem of params on the qemu-dm.

That's not safe enough since it always looks for a ':' regardless of whether the driver is 'tap' or not. It also doesn't take account of fact that the device may be named 'xvda' rather than 'hda'.

I posted patches to address this more completely here:

http://lists.xensource.com/archives/html/xen-devel/2007-06/msg01021.html

I'm attaching them again for convenience

Regards,
Dan.

Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
tools/ioemu/xenstore.c +2 -44
diff -r c0b0974fb055 tools/ioemu/xenstore.c
@@ -10,7 +10,6 @@
 
 #include "vl.h"
 #include "block_int.h"
-#include <unistd.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <sys/types.h>
@@ -61,28 +60,11 @@ void xenstore_check_new_media_present(in
     qemu_mod_timer(insert_timer, qemu_get_clock(rt_clock) + timeout);
 }
 
-static void waitForDevice(char *fn)
-{ 
-    struct stat sbuf;
-    int status;
-    int uwait = UWAIT_MAX;
-
-    do {
-        status = stat(fn, &sbuf);
-        if (!status) break;
-        usleep(UWAIT);
-        uwait -= UWAIT;
-    } while (uwait > 0);
-
-    return;
-}
-
 void xenstore_parse_domain_config(int domid)
 {
     char **e = NULL;
     char *buf = NULL, *path;
-    char *fpath = NULL, *bpath = NULL,
-        *dev = NULL, *params = NULL, *type = NULL;
+    char *bpath = NULL, *dev = NULL, *params = NULL, *type = NULL;
     int i, is_scsi;
     unsigned int len, num, hd_index;
 
@@ -140,36 +122,12 @@ void xenstore_parse_domain_config(int do
         params = xs_read(xsh, XBT_NULL, buf, &len);
         if (params == NULL)
             continue;
-        /* 
-         * check if device has a phantom vbd; the phantom is hooked
-         * to the frontend device (for ease of cleanup), so lookup 
-         * the frontend device, and see if there is a phantom_vbd
-         * if there is, we will use resolution as the filename
-         */
-        if (pasprintf(&buf, "%s/device/vbd/%s/phantom_vbd", path, e[i]) == -1)
-            continue;
-        free(fpath);
-        fpath = xs_read(xsh, XBT_NULL, buf, &len);
-        if (fpath) {
-            if (pasprintf(&buf, "%s/dev", fpath) == -1)
-                continue;
-            free(params);
-            params = xs_read(xsh, XBT_NULL, buf , &len);
-            if (params) {
-                /* 
-                 * wait for device, on timeout silently fail because we will 
-                 * fail to open below
-                 */
-                waitForDevice(params);
-            }
-        }
 
         bs_table[hd_index + (is_scsi ? MAX_DISKS : 0)] = bdrv_new(dev);
         /* check if it is a cdrom */
         if (type && !strcmp(type, "cdrom")) {
             bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM);
-            if (pasprintf(&buf, "%s/params", bpath) != -1)
-                xs_watch(xsh, buf, dev);
+	    xs_watch(xsh, buf, dev);
         }
         /* open device now if media present */
         if (params[0]) {
tools/python/xen/xend/XendConfig.py +0 -41

47 lines not on this page · raw message

tools/python/xen/xend/XendDomainInfo.py +1 -57

90 lines not on this page · raw message

tools/python/xen/xend/server/BlktapController.py +0 -62

72 lines not on this page · raw message

tools/python/xen/xend/server/DevController.py +0 -13
diff -r c0b0974fb055 tools/python/xen/xend/server/DevController.py
@@ -474,19 +474,6 @@ class DevController:
     def waitForBackend(self, devid):
 
         frontpath = self.frontendPath(devid)
-        # lookup a phantom 
-        phantomPath = xstransact.Read(frontpath, 'phantom_vbd')
-        if phantomPath is not None:
-            log.debug("Waiting for %s's phantom %s.", devid, phantomPath)
-            statusPath = phantomPath + '/' + HOTPLUG_STATUS_NODE
-            ev = Event()
-            result = { 'status': Timeout }
-            xswatch(statusPath, hotplugStatusCallback, ev, result)
-            ev.wait(DEVICE_CREATE_TIMEOUT)
-            err = xstransact.Read(statusPath, HOTPLUG_ERROR_NODE)
-            if result['status'] != 'Connected':
-                return (result['status'], err)
-            
         backpath = xstransact.Read(frontpath, "backend")
 
 
tools/ioemu/xenstore.c +17 -1
@@ -83,7 +83,7 @@ void xenstore_parse_domain_config(int do
     char *buf = NULL, *path;
     char *fpath = NULL, *bpath = NULL,
         *dev = NULL, *params = NULL, *type = NULL;
-    int i, is_scsi;
+    int i, is_scsi, is_tap = 0;
     unsigned int len, num, hd_index;
 
     for(i = 0; i < MAX_DISKS + MAX_SCSI_DISKS; i++)
@@ -123,6 +123,14 @@ void xenstore_parse_domain_config(int do
         dev = xs_read(xsh, XBT_NULL, buf, &len);
         if (dev == NULL)
             continue;
+	/* Force xvdN to look like  hdN */
+	if (!strncmp(dev, "xvd", 3)) {
+	  memmove(dev, dev+1, strlen(dev));
+	  dev[0] = 'h';
+	  dev[1] = 'd';
+	  is_tap = 1;
+	  fprintf(stderr, "Got blktap '%s'\n", dev);
+	}
         is_scsi = !strncmp(dev, "sd", 2);
         if ((strncmp(dev, "hd", 2) && !is_scsi) || strlen(dev) != 3 )
             continue;
@@ -140,6 +148,14 @@ void xenstore_parse_domain_config(int do
         params = xs_read(xsh, XBT_NULL, buf, &len);
         if (params == NULL)
             continue;
+	/* Strip off blktap sub-type prefix aio: etc */
+	if (is_tap) {
+	  char *offset = strchr(params, ':');
+	  if (!offset)
+	    continue;
+	  memmove(params, offset+1, strlen(offset+1)+1);
+	  fprintf(stderr, "Got params '%s'\n", params);
+	}
         /* 
          * check if device has a phantom vbd; the phantom is hooked
          * to the frontend device (for ease of cleanup), so lookup 

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

#2 lore raw

Re: [PATCH] Allow blktap to be able to be booted assystem volume for PV-on-HVM

Hi Daniel,

Thank you for the reply.

Quoted 2 lines

That's not safe enough since it always looks for a ':' regardless of whether the driver is 'tap' or not.

Does it mean to have to check the assumed keyword(aio,sync,qcow)? If it is so, I will correct the patch.

Quoted 2 lines

It also doesn't take account of
fact that the device may be named 'xvda' rather than 'hda'.

I saw the presented patches. The xvdN was forcedly looked like the hdN.
For example, the hdc is a special device named CDROM in qemu-dm.
Therefore, I think that it should not forcedly do it because it cannot take the consistency.

I think the HVM domain to be should boot on the hda as it is a specification of qemu-dm.

Best Regards,

--
Takanori Kasai

#3 lore raw

Re: [PATCH] Allow blktap to be able to be booted assystem volume for PV-on-HVM

Quoted 5 lines · Kasai Takanori
Quoted 2 lines

It also doesn't take account of
fact that the device may be named 'xvda' rather than 'hda'.

I saw the presented patches. The xvdN was forcedly looked like the hdN. For example, the hdc is a special device named CDROM in qemu-dm.

No that is wrong. Any hdX device can be a CDROM - whether it is a CDROM or not is determined by the :cdrom postfix, not the device name.

eg You can happily make hdc a harddisk:

tap:aio:/var/lib/xen/images/dom.img,hdc,w

Or make hda a CDROM

tap:aio:/var/lib/xen/images/dom.img,hda:cdrom,w

Quoted 2 lines

Therefore, I think that it should not forcedly do it because it cannot take the consistency.

Being able to use 'xvd*', as well as 'hd*' or 'sd*' as device names is important for consistency with paravirt guests, where xvd* is the recommended default.

Quoted 2 lines

I think the HVM domain to be should boot on the hda as it is a specification of qemu-dm.

It can do that. My patch made it possible to use either

tap:aio:/var/lib/xen/images/dom.img,hda,w

Or

tap:aio:/var/lib/xen/images/dom.img,xvda,w

At the user's choice.

n/

Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
#4 lore raw

Re: [PATCH] Allow blktap to be able to be booted assystemvolume for PV-on-HVM

Hi Daniel,

Thank you for the reply.

We think about the specification of the device as follows.

The hda is initialized of emulator first.
It works by the emulator if there is no PV driver in the HVM domain. It is initialized as VBD if there is PV driver in the HVM domain. And, the hda changes to VBD and works as VBD.

On the other hand, the xvda doesn't initialize it as an emulator.
It doesn't work if there is no PV driver in the HVM domain. It works as VBD if there is PV driver in the HVM domain.

The hda is used as a device from which the emulator is switched to VBD. And, the xvd* is used as a device only for VBD.

Therefore, the system disk is specified for hda as well as a usual HVM domain. Other data disks are specified for xvd*. We boot the HVM domain specifying both hda and xvda.

What scenario are you assuming?
Do you initialize all 'xvd*' as an emulator?

Best Regards,

--
Takanori Kasai