WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] QEMU "drive_init()" Disk Format Security Bypass

I wrote:
> Markus Armbruster writes ("Re: [Xen-devel] [PATCH] QEMU "drive_init()" Disk 
> Format Security Bypass"):
> > The -usbdevice argument is ultimately processed by usb_device_add(),
> > which calls usb_msd_init() to do the real work.  I think we get (1),
> > but not (2) there, i.e. your change breaks raw format USB disks.
> 
> That's quite likely.  I hadn't spotted that separate arrangement.  The
> best thing to do would be probably be to cross-port the format
> parameter code which upstream have introduced in this area to (mostly)
> fix the bug in their version.  I'll look into it.

The code in current qemu and in ioemu are very different in this area.
The machinery to which qemu added the format=... parameter doesn't
exist in ioemu and I don't think we want to backport that.

Instead below is a batch which is intended to make
   usbdevice = "disk:<filename>"
expect a raw device (as this probably is the most usual case) and
   usbdevice = "disk-qcow:<filename>"
expect a COW image (autodetected, probably qcow2).

This latter will eventually have to change to bring things into line
with recent qemu, but we can probably provide backwards compatibility
at that time.

Markus and Eren: could you please try this and let me know if it
solves the problem for you ?  I don't have a handy test setup here
right now.  If you can't conveniently test it let me know and I'll do
it.

Regards,
Ian.

diff -r a88e19526770 tools/ioemu/hw/usb-msd.c
--- a/tools/ioemu/hw/usb-msd.c  Fri Jun 13 15:31:35 2008 +0100
+++ b/tools/ioemu/hw/usb-msd.c  Fri Jun 13 16:08:34 2008 +0100
@@ -510,7 +510,7 @@ static void usb_msd_handle_destroy(USBDe
     qemu_free(s);
 }
 
-USBDevice *usb_msd_init(const char *filename)
+USBDevice *usb_msd_init(const char *filename, BlockDriver *drv)
 {
     MSDState *s;
     BlockDriverState *bdrv;
@@ -520,7 +520,7 @@ USBDevice *usb_msd_init(const char *file
         return NULL;
 
     bdrv = bdrv_new("usb");
-    if (bdrv_open(bdrv, filename, 0) < 0)
+    if (bdrv_open2(bdrv, filename, 0, drv) < 0)
         goto fail;
     s->bs = bdrv;
 
diff -r a88e19526770 tools/ioemu/hw/usb.h
--- a/tools/ioemu/hw/usb.h      Fri Jun 13 15:31:35 2008 +0100
+++ b/tools/ioemu/hw/usb.h      Fri Jun 13 16:08:05 2008 +0100
@@ -217,7 +217,7 @@ USBDevice *usb_tablet_init(void);
 USBDevice *usb_tablet_init(void);
 
 /* usb-msd.c */
-USBDevice *usb_msd_init(const char *filename);
+USBDevice *usb_msd_init(const char *filename, BlockDriver *drv);
 
 /* usb.c */
 void generic_usb_save(QEMUFile* f, void *opaque);
diff -r a88e19526770 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Fri Jun 13 15:31:35 2008 +0100
+++ b/tools/ioemu/vl.c  Fri Jun 13 16:08:51 2008 +0100
@@ -4260,7 +4260,9 @@ static int usb_device_add(const char *de
     } else if (!strcmp(devname, "tablet")) {
        dev = usb_tablet_init();
     } else if (strstart(devname, "disk:", &p)) {
-        dev = usb_msd_init(p);
+        dev = usb_msd_init(p, &bdrv_raw);
+    } else if (strstart(devname, "disk-qcow:", &p)) {
+        dev = usb_msd_init(p, 0);
     } else {
         return -1;
     }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel