From: Stefan Berger Date: Tue, 29 Jan 2013 16:52:17 +0000 (-0500) Subject: Add support for QEMU -add-fd support detection X-Git-Tag: v1.0.3-rc1~268 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=410b335d237e1c08e14dc16982f45349a3e780a2;p=thirdparty%2Flibvirt.git 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 --- diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 29693c339c..e390cb194d 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 #include #include #include @@ -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 5279d07605..cb0dad0706 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 */ };