From: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
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(a)redhat.com>
---
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);
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;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 5279d07..cb0dad0 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -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 */
};
--
1.8.1