[libvirt] [PATCH] Better error reporting in qemu AttachDevice

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

 



The attached patch fixes qemu AttachDevice to show the invalid disk bus
or type in it's error messages. This also adds an error message where
previously we could fall through, leading virsh to print 'Unknown Error'
if attempting to hotplug an IDE disk.

Thanks,
Cole
commit abc32756bebac926acc0fde94ea42d2df2ca9946
Author: Cole Robinson <crobinso@xxxxxxxxxx>
Date:   Fri Feb 27 10:48:22 2009 -0500

    Better error reporting from qemu AttachDevice

diff --git a/src/domain_conf.c b/src/domain_conf.c
index 603b87b..95ad32f 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -73,6 +73,14 @@ VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
               "rename-restart",
               "preserve")
 
+VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
+              "disk",
+              "filesystem",
+              "interface",
+              "input",
+              "sound",
+              "hostdev")
+
 VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
               "block",
               "file")
diff --git a/src/domain_conf.h b/src/domain_conf.h
index 491df06..015ea8b 100644
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -342,6 +342,8 @@ enum virDomainDeviceType {
     VIR_DOMAIN_DEVICE_INPUT,
     VIR_DOMAIN_DEVICE_SOUND,
     VIR_DOMAIN_DEVICE_HOSTDEV,
+
+    VIR_DOMAIN_DEVICE_LAST,
 };
 
 typedef struct _virDomainDeviceDef virDomainDeviceDef;
@@ -621,6 +623,7 @@ VIR_ENUM_DECL(virDomainVirt)
 VIR_ENUM_DECL(virDomainBoot)
 VIR_ENUM_DECL(virDomainFeature)
 VIR_ENUM_DECL(virDomainLifecycle)
+VIR_ENUM_DECL(virDomainDevice)
 VIR_ENUM_DECL(virDomainDisk)
 VIR_ENUM_DECL(virDomainDiskDevice)
 VIR_ENUM_DECL(virDomainDiskBus)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b8cca00..b8691a3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -68,6 +68,7 @@ virDomainDefParseString;
 virDomainDeleteConfig;
 virDomainDeviceDefFree;
 virDomainDeviceDefParse;
+virDomainDeviceTypeToString;
 virDomainDiskBusTypeToString;
 virDomainDiskDefFree;
 virDomainDiskDeviceTypeToString;
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 34854dd..3b9b08a 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -3470,17 +3470,25 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
         case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
             ret = qemudDomainChangeEjectableMedia(dom->conn, vm, dev);
             break;
+
         case VIR_DOMAIN_DISK_DEVICE_DISK:
             if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) {
                 ret = qemudDomainAttachUsbMassstorageDevice(dom->conn, vm, dev);
             } else if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_SCSI ||
                        dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
                 ret = qemudDomainAttachPciDiskDevice(dom->conn, vm, dev);
+            } else {
+                qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
+                                 _("disk bus '%s' cannot be hotplugged."),
+                                 virDomainDiskBusTypeToString(dev->data.disk->bus));
+                goto cleanup;
             }
             break;
+
         default:
             qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
-                             "%s", _("this disk device type cannot be attached"));
+                             _("disk device type '%s' cannot be hotplugged"),
+                             virDomainDiskDeviceTypeToString(dev->data.disk->device));
             goto cleanup;
         }
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
@@ -3489,7 +3497,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
         ret = qemudDomainAttachHostDevice(dom->conn, vm, dev);
     } else {
         qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
-                         "%s", _("this device type cannot be attached"));
+                         _("device type '%s' cannot be attached"),
+                         virDomainDeviceTypeToString(dev->type));
         goto cleanup;
     }
 
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]