|
|
c401cc |
From 61986f544f712b35a8fb6f31d4bd8e2822bfe5dc Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <61986f544f712b35a8fb6f31d4bd8e2822bfe5dc@dist-git>
|
|
|
c401cc |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:54:58 +0100
|
|
|
c401cc |
Subject: [PATCH] qemu: Migrate sheepdog source generation into common function
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
(cherry picked from commit eaa1539b2f1c73e39b1d5fbe770a6c5f44f7fd11)
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/qemu/qemu_command.c | 37 ++++++++++++++++++++++++-------------
|
|
|
c401cc |
1 file changed, 24 insertions(+), 13 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
c401cc |
index f305a5a..f45b681 100644
|
|
|
c401cc |
--- a/src/qemu/qemu_command.c
|
|
|
c401cc |
+++ b/src/qemu/qemu_command.c
|
|
|
c401cc |
@@ -3655,6 +3655,29 @@ qemuBuildNetworkDriveURI(int protocol,
|
|
|
c401cc |
break;
|
|
|
c401cc |
|
|
|
c401cc |
case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
|
|
|
c401cc |
+ if (!src) {
|
|
|
c401cc |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c401cc |
+ _("missing disk source for 'sheepdog' protocol"));
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+
|
|
|
c401cc |
+ if (nhosts == 0) {
|
|
|
c401cc |
+ if (virAsprintf(&ret, "sheepdog:%s", src) < 0)
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ } else if (nhosts == 1) {
|
|
|
c401cc |
+ if (virAsprintf(&ret, "sheepdog:%s:%s:%s",
|
|
|
c401cc |
+ hosts->name,
|
|
|
c401cc |
+ hosts->port ? hosts->port : "7000",
|
|
|
c401cc |
+ src) < 0)
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ } else {
|
|
|
c401cc |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c401cc |
+ _("protocol 'sheepdog' accepts up to one host"));
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
+ }
|
|
|
c401cc |
+
|
|
|
c401cc |
+ break;
|
|
|
c401cc |
+
|
|
|
c401cc |
case VIR_DOMAIN_DISK_PROTOCOL_RBD:
|
|
|
c401cc |
case VIR_DOMAIN_DISK_PROTOCOL_LAST:
|
|
|
c401cc |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c401cc |
@@ -3900,24 +3923,12 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
c401cc |
virBufferAddChar(&opt, ',');
|
|
|
c401cc |
break;
|
|
|
c401cc |
|
|
|
c401cc |
+ case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
|
|
|
c401cc |
case VIR_DOMAIN_DISK_PROTOCOL_GLUSTER:
|
|
|
c401cc |
case VIR_DOMAIN_DISK_PROTOCOL_ISCSI:
|
|
|
c401cc |
if (qemuBuildDriveURIString(conn, disk, &opt) < 0)
|
|
|
c401cc |
goto error;
|
|
|
c401cc |
break;
|
|
|
c401cc |
-
|
|
|
c401cc |
- case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
|
|
|
c401cc |
- if (disk->nhosts == 0) {
|
|
|
c401cc |
- virBufferEscape(&opt, ',', ",", "file=sheepdog:%s,",
|
|
|
c401cc |
- disk->src);
|
|
|
c401cc |
- } else {
|
|
|
c401cc |
- /* only one host is supported now */
|
|
|
c401cc |
- virBufferAsprintf(&opt, "file=sheepdog:%s:%s:",
|
|
|
c401cc |
- disk->hosts->name,
|
|
|
c401cc |
- disk->hosts->port ? disk->hosts->port : "7000");
|
|
|
c401cc |
- virBufferEscape(&opt, ',', ",", "%s,", disk->src);
|
|
|
c401cc |
- }
|
|
|
c401cc |
- break;
|
|
|
c401cc |
}
|
|
|
c401cc |
} else {
|
|
|
c401cc |
if ((actualType == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|