Re: [PATCH 2/2] Add support for QEMU -add-fd support detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/30/2013 11:21 PM, Eric Blake wrote:
From: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>

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@xxxxxxxxxx>
---

v1 was here:
https://www.redhat.com/archives/libvir-list/2013-January/msg02056.html

Okay, so most of v2 is mine, but I kept Stefan as author for his
contribution in adding just one capability named QEMU_CAPS_ADD_FD.

  src/qemu/qemu_capabilities.c | 22 +++++++++++++++++++++-
  src/qemu/qemu_capabilities.h |  1 +
  2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 29693c3..0820fe4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -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);

This checks for QMP support -> version 1.2.

          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);
+    }
+

Aren't you only detecting version 1.2 with this?

I thought we would need something along the lines of this example here:

    if (version >= 9000)
        qemuCapsSet(caps, QEMU_CAPS_VNC_COLON);

   Stefan

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]