[libvirt] [PATCH] qemu: Fix media eject with qemu-0.12.*

In qemu-0.12.* "device '...' is locked" message was changed to "Device ..." so libvirt was no longer detecting this as an error. --- bootstrap.conf | 1 + src/qemu/qemu_monitor_text.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 6070204..6e10828 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -63,6 +63,7 @@ sigpipe snprintf socket stpcpy +strcasestr strchrnul strndup strerror diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 75b2995..7ebe62e 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -934,7 +934,7 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon, /* If the command failed qemu prints: * device not found, device is locked ... * No message is printed on success it seems */ - if (strstr(reply, "device ")) { + if (strcasestr(reply, "device ")) { qemuReportError(VIR_ERR_OPERATION_FAILED, _("could not eject media on %s: %s"), devname, reply); goto cleanup; -- 1.7.4.1

On 03/29/2011 10:10 AM, Jiri Denemark wrote:
In qemu-0.12.* "device '...' is locked" message was changed to "Device ..." so libvirt was no longer detecting this as an error. --- bootstrap.conf | 1 + src/qemu/qemu_monitor_text.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf index 6070204..6e10828 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -63,6 +63,7 @@ sigpipe snprintf socket stpcpy +strcasestr strchrnul strndup strerror diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 75b2995..7ebe62e 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -934,7 +934,7 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon, /* If the command failed qemu prints: * device not found, device is locked ... * No message is printed on success it seems */ - if (strstr(reply, "device ")) { + if (strcasestr(reply, "device ")) { qemuReportError(VIR_ERR_OPERATION_FAILED, _("could not eject media on %s: %s"), devname, reply); goto cleanup;
Even though strcasestr is a non-standard function, you're using gnulib for it, so that shouldn't be a problem. And your change will work for both old and new qemus. ACK.

On 03/30/2011 12:16 PM, Laine Stump wrote:
+++ b/bootstrap.conf @@ -63,6 +63,7 @@ sigpipe snprintf socket stpcpy +strcasestr
Even though strcasestr is a non-standard function, you're using gnulib for it, so that shouldn't be a problem. And your change will work for both old and new qemus.
Technically, using c-strcasestr would be nicer than strcasestr (it doesn't have as many problems with multibyte characters, even though the particular substring we are searching for is not multibyte). But right now, it's LGPLv3+ in gnulib - I've put in a request to see if we can get that relaxed. Meanwhile, using strcasestr is appropriate.
ACK.
I concur, and think this is appropriate for 0.9.0 with minimal risk if you push now. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Mar 30, 2011 at 12:27:32 -0600, Eric Blake wrote:
On 03/30/2011 12:16 PM, Laine Stump wrote:
+++ b/bootstrap.conf @@ -63,6 +63,7 @@ sigpipe snprintf socket stpcpy +strcasestr
Even though strcasestr is a non-standard function, you're using gnulib for it, so that shouldn't be a problem. And your change will work for both old and new qemus.
Technically, using c-strcasestr would be nicer than strcasestr (it doesn't have as many problems with multibyte characters, even though the particular substring we are searching for is not multibyte). But right now, it's LGPLv3+ in gnulib - I've put in a request to see if we can get that relaxed.
Meanwhile, using strcasestr is appropriate.
ACK.
I concur, and think this is appropriate for 0.9.0 with minimal risk if you push now.
Thanks, pushed. Jirka
participants (3)
-
Eric Blake
-
Jiri Denemark
-
Laine Stump