[libvirt] [PATCH 0/2] Fix "unknown error" when starting qemu VM with empty network cdrom

Peter Krempa (2): qemu: command: Report error when formatting network source with protocol _NONE qemu: command: Check for empty network source when formatting drive cmd src/qemu/qemu_command.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.2.2

The function that formats the string for network drives would return error code but did not set the error message when called on storage source with VIR_STORAGE_NET_PROTOCOL_LAST or _NONE. Report an error in this case if it would ever be called in that way. --- src/qemu/qemu_command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7e6b95c..8dd7a76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3263,6 +3263,9 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_NONE: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected network protocol '%s'"), + virStorageNetProtocolTypeToString(src->protocol)); goto cleanup; } -- 2.2.2

On 03/24/2015 09:24 AM, Peter Krempa wrote:
The function that formats the string for network drives would return error code but did not set the error message when called on storage source with VIR_STORAGE_NET_PROTOCOL_LAST or _NONE.
Report an error in this case if it would ever be called in that way. --- src/qemu/qemu_command.c | 3 +++ 1 file changed, 3 insertions(+)
ACK
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7e6b95c..8dd7a76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3263,6 +3263,9 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_NONE: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected network protocol '%s'"), + virStorageNetProtocolTypeToString(src->protocol)); goto cleanup; }
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Use the virStorageSourceIsEmpty helper to determine whether the drive source is empty rather than checking for src->path. This will fix start of VM with empty network cdrom that would not report any error. --- src/qemu/qemu_command.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8dd7a76..43eecf8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3289,6 +3289,10 @@ qemuGetDriveSourceString(virStorageSourcePtr src, *source = NULL; + /* return 1 for empty sources */ + if (virStorageSourceIsEmpty(src)) + return 1; + if (conn) { if (actualType == VIR_STORAGE_TYPE_NETWORK && src->auth && @@ -3318,11 +3322,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src, case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: - if (!src->path) { - ret = 1; - goto cleanup; - } - if (VIR_STRDUP(*source, src->path) < 0) goto cleanup; -- 2.2.2

On 03/24/2015 09:24 AM, Peter Krempa wrote:
Use the virStorageSourceIsEmpty helper to determine whether the drive source is empty rather than checking for src->path. This will fix start of VM with empty network cdrom that would not report any error. --- src/qemu/qemu_command.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
ACK.
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8dd7a76..43eecf8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3289,6 +3289,10 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
*source = NULL;
+ /* return 1 for empty sources */ + if (virStorageSourceIsEmpty(src)) + return 1; + if (conn) { if (actualType == VIR_STORAGE_TYPE_NETWORK && src->auth && @@ -3318,11 +3322,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src, case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: - if (!src->path) { - ret = 1; - goto cleanup; - } - if (VIR_STRDUP(*source, src->path) < 0) goto cleanup;
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Mar 25, 2015 at 10:39:05 -0600, Eric Blake wrote:
On 03/24/2015 09:24 AM, Peter Krempa wrote:
Use the virStorageSourceIsEmpty helper to determine whether the drive source is empty rather than checking for src->path. This will fix start of VM with empty network cdrom that would not report any error. --- src/qemu/qemu_command.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
ACK.
Both patches are pushed now. Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa