]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add support for QEMU -add-fd support detection
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 29 Jan 2013 16:52:17 +0000 (11:52 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 31 Jan 2013 17:23:28 +0000 (10:23 -0700)
Add support for QEMU -add-fd command line parameter detection.
This intentionally rejects qemu 1.2, where 'add-fd' QMP did
not allow full control of set ids, and where there was no command
line counterpart, but accepts qemu 1.3.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h

index 29693c339c44b68cfaeb4f15ff7a574e2679d6c5..e390cb194db603d03c5fd2cb83657305f75d8a46 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * qemu_capabilities.c: QEMU capabilities generation
  *
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -39,6 +39,7 @@
 #include "virnodesuspend.h"
 #include "qemu_monitor.h"
 
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/wait.h>
@@ -203,6 +204,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
 
               "usb-serial", /* 125 */
               "usb-net",
+              "add-fd",
 
     );
 
@@ -1961,10 +1963,28 @@ qemuCapsProbeQMPCommands(qemuCapsPtr caps,
             qemuCapsSet(caps, QEMU_CAPS_DRIVE_MIRROR);
         else if (STREQ(name, "blockdev-snapshot-sync"))
             qemuCapsSet(caps, QEMU_CAPS_DISK_SNAPSHOT);
+        else if (STREQ(name, "add-fd"))
+            qemuCapsSet(caps, QEMU_CAPS_ADD_FD);
         VIR_FREE(name);
     }
     VIR_FREE(commands);
 
+    /* QMP add-fd was introduced in 1.2, but did not support
+     * management control of set numbering, and did not have a
+     * counterpart -add-fd command line option.  We require the
+     * add-fd features from 1.3 or later.  */
+    if (qemuCapsGet(caps, QEMU_CAPS_ADD_FD)) {
+        int fd = open("/dev/null", O_RDONLY);
+        if (fd < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("unable to probe for add-fd"));
+            return -1;
+        }
+        if (qemuMonitorAddFd(mon, 0, fd, "/dev/null") < 0)
+            qemuCapsClear(caps, QEMU_CAPS_ADD_FD);
+        VIR_FORCE_CLOSE(fd);
+    }
+
     return 0;
 }
 
index 5279d07605929b7878dbe09c21942d1b4fb2adad..cb0dad070698c0d613e8f0ac34c57831cb2ff741 100644 (file)
@@ -165,6 +165,7 @@ enum qemuCapsFlags {
     QEMU_CAPS_SCLP_S390          = 124, /* -device sclp* */
     QEMU_CAPS_DEVICE_USB_SERIAL  = 125, /* -device usb-serial */
     QEMU_CAPS_DEVICE_USB_NET     = 126, /* -device usb-net */
+    QEMU_CAPS_ADD_FD             = 127, /* -add-fd */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };