Add support for QEMU -add-fd support detection

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>
This commit is contained in:
Stefan Berger 2013-01-29 11:52:17 -05:00 committed by Eric Blake
parent 7b2c5893c2
commit 410b335d23
2 changed files with 22 additions and 1 deletions

View 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;
}

View 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 */
};