[PATCHv1.5 08/27] qemu: Migrate sheepdog source generation into common function

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

 



---
 src/qemu/qemu_command.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 09ebd00..6ba8df9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3754,6 +3754,29 @@ qemuBuildNetworkDriveURI(int protocol,
             break;

         case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
+            if (!src) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("missing disk source for 'sheepdog' protocol"));
+                goto cleanup;
+            }
+
+            if (nhosts == 0) {
+                if (virAsprintf(&ret, "sheepdog:%s", src) < 0)
+                    goto cleanup;
+            } else if (nhosts == 1) {
+                if (virAsprintf(&ret, "sheepdog:%s:%s:%s",
+                                hosts->name,
+                                hosts->port ? hosts->port : "7000",
+                                src) < 0)
+                    goto cleanup;
+            } else {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("protocol 'sheepdog' accepts up to one host"));
+                goto cleanup;
+            }
+
+            break;
+
         case VIR_DOMAIN_DISK_PROTOCOL_RBD:
         case VIR_DOMAIN_DISK_PROTOCOL_LAST:
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4001,6 +4024,7 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
                 virBufferAddChar(&opt, ',');
                 break;

+            case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
             case VIR_DOMAIN_DISK_PROTOCOL_TFTP:
             case VIR_DOMAIN_DISK_PROTOCOL_FTPS:
             case VIR_DOMAIN_DISK_PROTOCOL_FTP:
@@ -4011,19 +4035,6 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
                 if (qemuBuildDriveURIString(conn, disk, &opt) < 0)
                     goto error;
                 break;
-
-            case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
-                if (disk->nhosts == 0) {
-                    virBufferEscape(&opt, ',', ",", "file=sheepdog:%s,",
-                                    disk->src);
-                } else {
-                    /* only one host is supported now */
-                    virBufferAsprintf(&opt, "file=sheepdog:%s:%s:",
-                                      disk->hosts->name,
-                                      disk->hosts->port ? disk->hosts->port : "7000");
-                    virBufferEscape(&opt, ',', ",", "%s,", disk->src);
-                }
-                break;
             }
         } else {
             if ((actualType == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
-- 
1.8.4.3

--
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]