Currently the protocol type with index 0 was NBD which made it hard to
distinguish whether the protocol type was actually assigned. Add a new
protocol type with index 0 to distinguish it explicitly.
---
Notes:
Version 2:
- fixed condition in virDomainDiskSourceParse so that "none" isn't
accepted
- fixed typo in comment in qemuNetworkDriveGetPort()
- fixed commit message
src/conf/domain_conf.c | 2 +-
src/qemu/qemu_command.c | 5 ++++-
src/qemu/qemu_driver.c | 3 +++
src/util/virstoragefile.c | 1 +
src/util/virstoragefile.h | 1 +
5 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4bc71c8..4fb2e1d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4989,7 +4989,7 @@ virDomainDiskSourceParse(xmlNodePtr node,
goto cleanup;
}
- if ((src->protocol = virStorageNetProtocolTypeFromString(protocol)) < 0){
+ if ((src->protocol = virStorageNetProtocolTypeFromString(protocol)) <= 0){
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown protocol type '%s'"), protocol);
goto cleanup;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 31d0781..0a7b2ff 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3046,7 +3046,8 @@ qemuNetworkDriveGetPort(int protocol,
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_LAST:
- /* not aplicable */
+ case VIR_STORAGE_NET_PROTOCOL_NONE:
+ /* not applicable */
return -1;
}
@@ -3262,6 +3263,7 @@ qemuBuildNetworkDriveURI(int protocol,
case VIR_STORAGE_NET_PROTOCOL_LAST:
+ case VIR_STORAGE_NET_PROTOCOL_NONE:
goto cleanup;
}
@@ -11080,6 +11082,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
case VIR_STORAGE_NET_PROTOCOL_FTPS:
case VIR_STORAGE_NET_PROTOCOL_TFTP:
case VIR_STORAGE_NET_PROTOCOL_LAST:
+ case VIR_STORAGE_NET_PROTOCOL_NONE:
/* ignored for now */
break;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d3e14ea..2b852eb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12390,6 +12390,7 @@
qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
case VIR_STORAGE_TYPE_NETWORK:
switch ((virStorageNetProtocol) disk->src.protocol) {
+ case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
@@ -12455,6 +12456,7 @@
qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
return 0;
+ case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
@@ -12597,6 +12599,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
case VIR_STORAGE_TYPE_NETWORK:
switch ((virStorageNetProtocol) disk->src.protocol) {
+ case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD:
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 856b726..b90cdc9 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -72,6 +72,7 @@ VIR_ENUM_IMPL(virStorageFileFeature,
)
VIR_ENUM_IMPL(virStorageNetProtocol, VIR_STORAGE_NET_PROTOCOL_LAST,
+ "none",
"nbd",
"rbd",
"sheepdog",
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index d3560a8..082ff5b 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -119,6 +119,7 @@ struct _virStorageTimestamps {
/* Information related to network storage */
typedef enum {
+ VIR_STORAGE_NET_PROTOCOL_NONE,
VIR_STORAGE_NET_PROTOCOL_NBD,
VIR_STORAGE_NET_PROTOCOL_RBD,
VIR_STORAGE_NET_PROTOCOL_SHEEPDOG,
--
1.9.3