[libvirt] [PATCH] Remove inappropriate use of VIR_ERR_NO_SUPPORT

Daniel P. Berrange dan at berrange.com
Thu Jul 15 16:53:33 UTC 2010


The VIR_ERR_NO_SUPPORT refers to an API which is not implemented.
There is a separate VIR_ERR_CONFIG_UNSUPPORTED for XML config
options that are not available with the current hypervisor.

* src/qemu/qemu_conf.c, src/qemu/qemu_driver.c: Remove
  many VIR_ERR_NO_SUPPORT replace with VIR_ERR_CONFIG_UNSUPPORTED
---
 src/qemu/qemu_conf.c   |   18 +++++++++---------
 src/qemu/qemu_driver.c |   36 ++++++++++++++++++------------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1d0bd88..4fee43e 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1839,7 +1839,7 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk)
         ret = virAsprintf(&devname, "xenblk%d", devid);
         break;
     default:
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("Unsupported disk name mapping for bus '%s'"),
                         virDomainDiskBusTypeToString(disk->bus));
         return -1;
@@ -3390,7 +3390,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
             goto cleanup;
 
         if (!ncpus || !host) {
-            qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                             _("CPU specification not supported by hypervisor"));
             goto cleanup;
         }
@@ -3564,7 +3564,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
     if (migrateFrom) {
         if (STRPREFIX(migrateFrom, "tcp")) {
             if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP)) {
-                qemuReportError(VIR_ERR_NO_SUPPORT,
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 "%s", _("TCP migration is not supported with this QEMU binary"));
                 return -1;
             }
@@ -3572,13 +3572,13 @@ int qemudBuildCommandLine(virConnectPtr conn,
             if (qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC) {
                 migrateFrom = "exec:cat";
             } else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO)) {
-                qemuReportError(VIR_ERR_NO_SUPPORT,
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 "%s", _("STDIO migration is not supported with this QEMU binary"));
                 return -1;
             }
         } else if (STRPREFIX(migrateFrom, "exec")) {
             if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC)) {
-                qemuReportError(VIR_ERR_NO_SUPPORT,
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 "%s", _("STDIO migration is not supported with this QEMU binary"));
                 return -1;
             }
@@ -4030,7 +4030,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
             /* QEMU doesn't implement a SATA driver */
             if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
-                qemuReportError(VIR_ERR_NO_SUPPORT,
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 "%s", _("SATA is not supported with this QEMU binary"));
                 goto error;
             }
@@ -4386,7 +4386,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
         case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
             if (!(qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) ||
                 !(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
-                qemuReportError(VIR_ERR_NO_SUPPORT,
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 "%s", _("guestfwd requires QEMU to support -chardev & -device"));
                 goto error;
             }
@@ -4411,7 +4411,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
         case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
             if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
-                qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                     _("virtio channel requires QEMU to support -device"));
                 goto error;
             }
@@ -4743,7 +4743,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
                     goto error;
                 ADD_ARG(devstr);
             } else {
-                qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                 _("PCI device assignment is not supported by this version of qemu"));
                 goto error;
             }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 96277cd..21ae084 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -809,7 +809,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
     enc = disk->encryption;
 
     if (!conn) {
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_INTERNAL_ERROR,
                         "%s", _("cannot find secrets without a connection"));
         goto cleanup;
     }
@@ -7540,7 +7540,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
     int vlan;
 
     if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HOST_NET_ADD)) {
-        qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                         _("installed qemu version does not support host_net_add"));
         return -1;
     }
@@ -7548,7 +7548,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
     if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
         net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
         if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
-            qemuReportError(VIR_ERR_NO_SUPPORT,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("network device type '%s' cannot be attached: "
                               "qemu is not using a unix socket monitor"),
                             virDomainNetTypeToString(net->type));
@@ -7559,7 +7559,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
             return -1;
     } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
         if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
-            qemuReportError(VIR_ERR_NO_SUPPORT,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("network device type '%s' cannot be attached: "
                             "qemu is not using a unix socket monitor"),
                             virDomainNetTypeToString(net->type));
@@ -7592,7 +7592,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
         vlan = qemuDomainNetVLAN(net);
 
         if (vlan < 0) {
-            qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                             _("Unable to attach network devices without vlan"));
             goto cleanup;
         }
@@ -7928,7 +7928,7 @@ static int qemudDomainAttachHostDevice(struct qemud_driver *driver,
                                        unsigned long long qemuCmdFlags)
 {
     if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("hostdev mode '%s' not supported"),
                         virDomainHostdevModeTypeToString(hostdev->mode));
         return -1;
@@ -7970,7 +7970,7 @@ static int qemudDomainAttachHostDevice(struct qemud_driver *driver,
         break;
 
     default:
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("hostdev subsys type '%s' not supported"),
                         virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type));
         goto error;
@@ -8066,7 +8066,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
                 if (ret == 0)
                     dev->data.disk = NULL;
             } else {
-                qemuReportError(VIR_ERR_NO_SUPPORT,
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 _("disk bus '%s' cannot be hotplugged."),
                                 virDomainDiskBusTypeToString(dev->data.disk->bus));
                 /* fallthrough */
@@ -8074,7 +8074,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
             break;
 
         default:
-            qemuReportError(VIR_ERR_NO_SUPPORT,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("disk device type '%s' cannot be hotplugged"),
                             virDomainDiskDeviceTypeToString(dev->data.disk->device));
             /* Fallthrough */
@@ -8091,7 +8091,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
             if (ret == 0)
                 dev->data.controller = NULL;
         } else {
-            qemuReportError(VIR_ERR_NO_SUPPORT,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("disk controller bus '%s' cannot be hotplugged."),
                             virDomainControllerTypeToString(dev->data.controller->type));
             /* fallthrough */
@@ -8107,7 +8107,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
         if (ret == 0)
             dev->data.hostdev = NULL;
     } else {
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("device type '%s' cannot be attached"),
                         virDomainDeviceTypeToString(dev->type));
         goto endjob;
@@ -8296,7 +8296,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
 
 
         default:
-            qemuReportError(VIR_ERR_NO_SUPPORT,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("disk bus '%s' cannot be updated."),
                             virDomainDiskBusTypeToString(dev->data.disk->bus));
             break;
@@ -8314,7 +8314,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
         break;
 
     default:
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("disk device type '%s' cannot be updated"),
                         virDomainDiskDeviceTypeToString(dev->data.disk->device));
         break;
@@ -8892,7 +8892,7 @@ static int qemudDomainDetachHostDevice(struct qemud_driver *driver,
     int ret;
 
     if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("hostdev mode '%s' not supported"),
                         virDomainHostdevModeTypeToString(hostdev->mode));
         return -1;
@@ -8906,7 +8906,7 @@ static int qemudDomainDetachHostDevice(struct qemud_driver *driver,
         ret = qemudDomainDetachHostUsbDevice(driver, vm, dev, qemuCmdFlags);
         break;
     default:
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("hostdev subsys type '%s' not supported"),
                         virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type));
         return -1;
@@ -8967,7 +8967,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
                                                   qemuCmdFlags);
         }
         else {
-            qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                             _("This type of disk cannot be hot unplugged"));
         }
     } else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
@@ -8977,7 +8977,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
             ret = qemudDomainDetachPciControllerDevice(driver, vm, dev,
                                                        qemuCmdFlags);
         } else {
-            qemuReportError(VIR_ERR_NO_SUPPORT,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("disk controller bus '%s' cannot be hotunplugged."),
                             virDomainControllerTypeToString(dev->data.controller->type));
             /* fallthrough */
@@ -8985,7 +8985,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
         ret = qemudDomainDetachHostDevice(driver, vm, dev, qemuCmdFlags);
     } else {
-        qemuReportError(VIR_ERR_NO_SUPPORT,
+        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         "%s", _("This type of device cannot be hot unplugged"));
     }
 
-- 
1.7.1.1




More information about the libvir-list mailing list