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

Re: [Xen-devel] Xex 4.3.1 issues with HVM + drbd (qemu-system-i386 No such file or directory)



On 01/04/14 00:51, Miguel Clara wrote:
> 
> I'm trying to use drbd disks in a FreeBSD HVM+PV guest but it seems Xnew
> qemu doesn't want to do it, this is the error I get:
> 
> 
> cat /var/log/xen/qemu-dm-freebsd-01.log
> 
> qemu-system-i386: -drive
> file=drbd-freebsd-01,if=ide,index=0,media=disk,format=raw,cache=writeback:
> could not open disk image drbd-freebsd-01: No such file or directory
> 
> 
> I wil ltry with qemu-traditonal but wonder if this is a known issue...

The issue comes from the fact that drbd block devices are not known 
until the hotplug script is executed, but even then, the resulting 
block device that's passed into blkback is not written anywhere (apart 
from the major:minor numbers written to xenstore). One solution to the 
problem is to use qemu-xen-traditional stubdomains, but this is not 
available with qemu-xen yet.

I have a crappy patch that fetches the major:minor numbers from 
xenstore after the hotplug script has run and passes that to qemu-xen 
command line, I think it should solve the problem, but I don't have a 
drbd setup in order to test it, could you please give it a spin?

If this works OK I can clean the patch and properly submit it.

---
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 8abed7b..7c903ab 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -42,6 +42,39 @@ static const char *qemu_xen_path(libxl__gc *gc)
 #endif
 }
 
+static const char *qemu_fetch_device_path(libxl__gc *gc, uint32_t domid,
+                                          const libxl_device_disk *disk)
+{
+    libxl__device device;
+    char *be_path;
+    const char *phys_dev;
+    unsigned int major, minor;
+    int rc;
+
+    if (disk->backend != LIBXL_DISK_BACKEND_PHY)
+        return disk->pdev_path;
+
+    rc = libxl__device_from_disk(gc, domid, (libxl_device_disk *)disk, 
&device);
+    if (rc)
+        return NULL;
+
+    be_path = libxl__device_backend_path(gc, &device);
+    if (!be_path)
+        return NULL;
+
+    rc =  libxl__xs_read_checked(gc, XBT_NULL,
+                                 GCSPRINTF("%s/physical-device", be_path),
+                                 &phys_dev);
+    if (rc)
+        return NULL;
+
+    rc = sscanf(phys_dev, "%x:%x", &major, &minor);
+    if (rc != 2)
+        return NULL;
+
+    return GCSPRINTF("/dev/block/%u:%u", major, minor);
+}
+
 static int libxl__create_qemu_logfile(libxl__gc *gc, char *name)
 {
     char *logfile;
@@ -694,7 +727,8 @@ static char ** libxl__build_device_model_args_new(libxl__gc 
*gc,
                 else
                     drive = libxl__sprintf
                         (gc, 
"file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback,id=ide-%i",
-                         disks[i].pdev_path, disk, format, dev_number);
+                         qemu_fetch_device_path(gc, guest_domid, &disks[i]),
+                         disk, format, dev_number);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
                     LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support"
@@ -717,11 +751,13 @@ static char ** 
libxl__build_device_model_args_new(libxl__gc *gc,
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
                     drive = libxl__sprintf
                         (gc, 
"file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback",
-                         disks[i].pdev_path, disk, format);
+                         qemu_fetch_device_path(gc, guest_domid, &disks[i]),
+                         disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
                         (gc, 
"file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
-                         disks[i].pdev_path, disk, format);
+                         qemu_fetch_device_path(gc, guest_domid, &disks[i]),
+                         disk, format);
                 else
                     continue; /* Do not emulate this disk */
             }


_______________________________________________
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®.