2009-06-11 14:17:42 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2013-04-16 13:41:44 +00:00
|
|
|
#include "testutils.h"
|
|
|
|
|
2009-06-11 14:17:42 +00:00
|
|
|
#ifdef WITH_QEMU
|
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdlib.h>
|
2009-06-11 14:17:42 +00:00
|
|
|
|
2010-12-17 16:41:51 +00:00
|
|
|
# include "qemu/qemu_capabilities.h"
|
2017-04-05 13:38:37 +00:00
|
|
|
# define __QEMU_CAPSPRIV_H_ALLOW__
|
|
|
|
# include "qemu/qemu_capspriv.h"
|
|
|
|
# undef __QEMU_CAPSPRIV_H_ALLOW__
|
|
|
|
|
2012-12-12 18:06:53 +00:00
|
|
|
# include "viralloc.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
# include "virstring.h"
|
2009-06-11 14:17:42 +00:00
|
|
|
|
2013-06-07 15:10:28 +00:00
|
|
|
# define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2009-06-11 14:17:42 +00:00
|
|
|
struct testInfo {
|
|
|
|
const char *name;
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr flags;
|
2010-02-09 13:06:56 +00:00
|
|
|
unsigned int version;
|
2013-05-24 10:47:17 +00:00
|
|
|
bool is_kvm;
|
2010-02-09 13:06:56 +00:00
|
|
|
unsigned int kvm_version;
|
2014-11-12 15:49:59 +00:00
|
|
|
int error;
|
2009-06-11 14:17:42 +00:00
|
|
|
};
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
static void printMismatchedFlags(virQEMUCapsPtr got,
|
|
|
|
virQEMUCapsPtr expect)
|
2009-12-21 20:36:32 +00:00
|
|
|
{
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2009-12-21 20:36:32 +00:00
|
|
|
|
2013-05-21 07:53:48 +00:00
|
|
|
for (i = 0; i < QEMU_CAPS_LAST; i++) {
|
2013-02-01 13:48:58 +00:00
|
|
|
bool gotFlag = virQEMUCapsGet(got, i);
|
|
|
|
bool expectFlag = virQEMUCapsGet(expect, i);
|
2009-12-21 20:36:32 +00:00
|
|
|
if (gotFlag && !expectFlag)
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
fprintf(stderr, "Extra flag %zu\n", i);
|
2009-12-21 20:36:32 +00:00
|
|
|
if (!gotFlag && expectFlag)
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
fprintf(stderr, "Missing flag %zu\n", i);
|
2009-12-21 20:36:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-11 14:17:42 +00:00
|
|
|
static int testHelpStrParsing(const void *data)
|
|
|
|
{
|
|
|
|
const struct testInfo *info = data;
|
2011-01-13 16:09:15 +00:00
|
|
|
char *path = NULL;
|
2011-04-24 22:25:10 +00:00
|
|
|
char *help = NULL;
|
2013-05-24 10:47:17 +00:00
|
|
|
unsigned int version, kvm_version;
|
|
|
|
bool is_kvm;
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsPtr flags = NULL;
|
2011-01-13 16:09:15 +00:00
|
|
|
int ret = -1;
|
2011-02-08 14:22:39 +00:00
|
|
|
char *got = NULL;
|
|
|
|
char *expected = NULL;
|
2009-06-11 14:17:42 +00:00
|
|
|
|
2011-01-13 16:09:15 +00:00
|
|
|
if (virAsprintf(&path, "%s/qemuhelpdata/%s", abs_srcdir, info->name) < 0)
|
|
|
|
return -1;
|
2009-06-11 14:17:42 +00:00
|
|
|
|
2016-05-26 15:01:52 +00:00
|
|
|
if (virTestLoadFile(path, &help) < 0)
|
2011-01-13 16:09:15 +00:00
|
|
|
goto cleanup;
|
2009-06-11 14:17:42 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!(flags = virQEMUCapsNew()))
|
2011-02-08 14:22:39 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsParseHelpStr("QEMU", help, flags,
|
2014-12-04 15:26:41 +00:00
|
|
|
&version, &is_kvm, &kvm_version, false, NULL) == -1) {
|
2016-07-18 18:25:43 +00:00
|
|
|
virErrorPtr err = virGetLastError();
|
|
|
|
|
|
|
|
if (info->error && err && err->code == info->error)
|
2014-11-12 15:49:59 +00:00
|
|
|
ret = 0;
|
2011-01-13 16:09:15 +00:00
|
|
|
goto cleanup;
|
2014-11-12 15:49:59 +00:00
|
|
|
}
|
2011-01-13 16:09:15 +00:00
|
|
|
|
2012-09-20 11:57:13 +00:00
|
|
|
# ifndef WITH_YAJL
|
2013-02-01 13:48:58 +00:00
|
|
|
if (virQEMUCapsGet(info->flags, QEMU_CAPS_MONITOR_JSON))
|
|
|
|
virQEMUCapsSet(flags, QEMU_CAPS_MONITOR_JSON);
|
2011-10-20 20:36:32 +00:00
|
|
|
# endif
|
|
|
|
|
2016-05-20 12:33:58 +00:00
|
|
|
VIR_FREE(path);
|
|
|
|
VIR_FREE(help);
|
|
|
|
if (virAsprintf(&path, "%s/qemuhelpdata/%s-device", abs_srcdir,
|
|
|
|
info->name) < 0)
|
|
|
|
goto cleanup;
|
2011-01-13 16:09:15 +00:00
|
|
|
|
2016-05-26 15:01:52 +00:00
|
|
|
if (virTestLoadFile(path, &help) < 0)
|
2016-05-20 12:33:58 +00:00
|
|
|
goto cleanup;
|
2011-01-13 16:09:15 +00:00
|
|
|
|
2016-05-20 12:33:58 +00:00
|
|
|
if (virQEMUCapsParseDeviceStr(flags, help) < 0)
|
|
|
|
goto cleanup;
|
2009-06-11 14:17:42 +00:00
|
|
|
|
2013-02-01 13:48:58 +00:00
|
|
|
got = virQEMUCapsFlagsString(flags);
|
|
|
|
expected = virQEMUCapsFlagsString(info->flags);
|
2011-02-08 14:22:39 +00:00
|
|
|
if (!got || !expected)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (STRNEQ(got, expected)) {
|
2015-04-23 17:38:00 +00:00
|
|
|
VIR_TEST_DEBUG("%s: computed flags do not match: got %s, expected %s\n",
|
|
|
|
info->name, got, expected);
|
2009-12-21 20:36:32 +00:00
|
|
|
|
2011-12-20 01:08:29 +00:00
|
|
|
if (virTestGetDebug())
|
2009-12-21 20:36:32 +00:00
|
|
|
printMismatchedFlags(flags, info->flags);
|
|
|
|
|
2011-01-13 16:09:15 +00:00
|
|
|
goto cleanup;
|
2009-06-11 14:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (version != info->version) {
|
2011-09-21 16:29:31 +00:00
|
|
|
fprintf(stderr, "%s: parsed versions do not match: got %u, expected %u\n",
|
|
|
|
info->name, version, info->version);
|
2011-01-13 16:09:15 +00:00
|
|
|
goto cleanup;
|
2009-06-11 14:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_kvm != info->is_kvm) {
|
2011-01-13 16:09:15 +00:00
|
|
|
fprintf(stderr,
|
2011-09-21 16:29:31 +00:00
|
|
|
"%s: parsed is_kvm flag does not match: got %u, expected %u\n",
|
|
|
|
info->name, is_kvm, info->is_kvm);
|
2011-01-13 16:09:15 +00:00
|
|
|
goto cleanup;
|
2009-06-11 14:17:42 +00:00
|
|
|
}
|
|
|
|
|
2009-12-21 20:36:32 +00:00
|
|
|
if (kvm_version != info->kvm_version) {
|
2011-01-13 16:09:15 +00:00
|
|
|
fprintf(stderr,
|
2011-09-21 16:29:31 +00:00
|
|
|
"%s: parsed KVM versions do not match: got %u, expected %u\n",
|
|
|
|
info->name, kvm_version, info->kvm_version);
|
2011-01-13 16:09:15 +00:00
|
|
|
goto cleanup;
|
2009-06-11 14:17:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 16:09:15 +00:00
|
|
|
ret = 0;
|
2014-03-25 06:53:44 +00:00
|
|
|
cleanup:
|
2011-01-13 16:09:15 +00:00
|
|
|
VIR_FREE(path);
|
2011-04-24 22:25:10 +00:00
|
|
|
VIR_FREE(help);
|
2012-08-20 16:44:14 +00:00
|
|
|
virObjectUnref(flags);
|
2011-02-08 14:22:39 +00:00
|
|
|
VIR_FREE(got);
|
|
|
|
VIR_FREE(expected);
|
2011-01-13 16:09:15 +00:00
|
|
|
return ret;
|
2009-06-11 14:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-04-29 16:21:20 +00:00
|
|
|
mymain(void)
|
2009-06-11 14:17:42 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2014-11-12 15:49:59 +00:00
|
|
|
# define DO_TEST_FULL(name, version, is_kvm, kvm_version, error, ...) \
|
2011-02-08 14:22:39 +00:00
|
|
|
do { \
|
|
|
|
struct testInfo info = { \
|
2014-11-12 15:49:59 +00:00
|
|
|
name, NULL, version, is_kvm, kvm_version, error \
|
2011-02-08 14:22:39 +00:00
|
|
|
}; \
|
2013-02-01 13:48:58 +00:00
|
|
|
if (!(info.flags = virQEMUCapsNew())) \
|
2011-02-08 14:22:39 +00:00
|
|
|
return EXIT_FAILURE; \
|
2013-02-01 13:48:58 +00:00
|
|
|
virQEMUCapsSetList(info.flags, __VA_ARGS__, QEMU_CAPS_LAST); \
|
2016-05-26 15:01:50 +00:00
|
|
|
if (virTestRun("QEMU Help String Parsing " name, \
|
|
|
|
testHelpStrParsing, &info) < 0) \
|
2011-02-08 14:22:39 +00:00
|
|
|
ret = -1; \
|
2012-08-20 16:44:14 +00:00
|
|
|
virObjectUnref(info.flags); \
|
2009-06-11 14:17:42 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-11-12 15:49:59 +00:00
|
|
|
# define DO_TEST(name, version, is_kvm, kvm_version, ...) \
|
|
|
|
DO_TEST_FULL(name, version, is_kvm, kvm_version, VIR_ERR_OK, __VA_ARGS__)
|
|
|
|
|
2011-02-08 14:22:39 +00:00
|
|
|
DO_TEST("qemu-0.12.1", 12001, 0, 0,
|
|
|
|
QEMU_CAPS_DRIVE_SERIAL,
|
|
|
|
QEMU_CAPS_ENABLE_KVM,
|
|
|
|
QEMU_CAPS_SDL,
|
|
|
|
QEMU_CAPS_RTC,
|
|
|
|
QEMU_CAPS_NO_HPET,
|
|
|
|
QEMU_CAPS_BOOT_MENU,
|
|
|
|
QEMU_CAPS_NAME_PROCESS,
|
|
|
|
QEMU_CAPS_SMBIOS_TYPE,
|
2011-02-07 14:54:08 +00:00
|
|
|
QEMU_CAPS_VGA_NONE,
|
2011-09-21 08:25:29 +00:00
|
|
|
QEMU_CAPS_DRIVE_AIO,
|
2016-09-22 14:32:08 +00:00
|
|
|
QEMU_CAPS_PIIX3_USB_UHCI,
|
|
|
|
QEMU_CAPS_PIIX4_USB_UHCI,
|
|
|
|
QEMU_CAPS_USB_HUB,
|
2011-09-20 17:31:52 +00:00
|
|
|
QEMU_CAPS_NO_SHUTDOWN,
|
qemu: add new disk device='lun' for bus='virtio' & type='block'
In the past, generic SCSI commands issued from a guest to a virtio
disk were always passed through to the underlying disk by qemu, and
the kernel would also pass them on.
As a result of CVE-2011-4127 (see:
http://seclists.org/oss-sec/2011/q4/536), qemu now honors its
scsi=on|off device option for virtio-blk-pci (which enables/disables
passthrough of generic SCSI commands), and the kernel will only allow
the commands for physical devices (not for partitions or logical
volumes). The default behavior of qemu is still to allow sending
generic SCSI commands to physical disks that are presented to a guest
as virtio-blk-pci devices, but libvirt prefers to disable those
commands in the standard virtio block devices, enabling it only when
specifically requested (hopefully indicating that the requester
understands what they're asking for). For this purpose, a new libvirt
disk device type (device='lun') has been created.
device='lun' is identical to the default device='disk', except that:
1) It is only allowed if bus='virtio', type='block', and the qemu
version is "new enough" to support it ("new enough" == qemu 0.11 or
better), otherwise the domain will fail to start and a
CONFIG_UNSUPPORTED error will be logged).
2) The option "scsi=on" will be added to the -device arg to allow
SG_IO commands (if device !='lun', "scsi=off" will be added to the
-device arg so that SG_IO commands are specifically forbidden).
Guests which continue to use disk device='disk' (the default) will no
longer be able to use SG_IO commands on the disk; those that have
their disk device changed to device='lun' will still be able to use SG_IO
commands.
*docs/formatdomain.html.in - document the new device attribute value.
*docs/schemas/domaincommon.rng - allow it in the RNG
*tests/* - update the args of several existing tests to add scsi=off, and
add one new test that will test scsi=on.
*src/conf/domain_conf.c - update domain XML parser and formatter
*src/qemu/qemu_(command|driver|hotplug).c - treat
VIR_DOMAIN_DISK_DEVICE_LUN *almost* identically to
VIR_DOMAIN_DISK_DEVICE_DISK, except as indicated above.
Note that no support for this new device value was added to any
hypervisor drivers other than qemu, because it's unclear what it might
mean (if anything) to those drivers.
2012-01-05 03:48:38 +00:00
|
|
|
QEMU_CAPS_NO_ACPI,
|
2016-09-22 14:32:08 +00:00
|
|
|
QEMU_CAPS_SCSI_LSI,
|
|
|
|
QEMU_CAPS_VNC,
|
|
|
|
QEMU_CAPS_DEVICE_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_CIRRUS_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA,
|
|
|
|
QEMU_CAPS_DEVICE_USB_SERIAL,
|
|
|
|
QEMU_CAPS_DEVICE_USB_NET,
|
|
|
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC,
|
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE,
|
|
|
|
QEMU_CAPS_DEVICE_USB_KBD,
|
|
|
|
QEMU_CAPS_DEVICE_RTL8139,
|
|
|
|
QEMU_CAPS_DEVICE_E1000,
|
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET);
|
2011-02-08 14:22:39 +00:00
|
|
|
DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0,
|
|
|
|
QEMU_CAPS_DRIVE_BOOT,
|
|
|
|
QEMU_CAPS_KVM,
|
|
|
|
QEMU_CAPS_DRIVE_SERIAL,
|
|
|
|
QEMU_CAPS_MEM_PATH,
|
|
|
|
QEMU_CAPS_SDL,
|
2016-09-22 14:37:28 +00:00
|
|
|
QEMU_CAPS_ENABLE_KVM,
|
2011-02-08 14:22:39 +00:00
|
|
|
QEMU_CAPS_RTC,
|
|
|
|
QEMU_CAPS_NO_HPET,
|
|
|
|
QEMU_CAPS_NO_KVM_PIT,
|
|
|
|
QEMU_CAPS_TDF,
|
|
|
|
QEMU_CAPS_BOOT_MENU,
|
|
|
|
QEMU_CAPS_NESTING,
|
|
|
|
QEMU_CAPS_NAME_PROCESS,
|
|
|
|
QEMU_CAPS_SMBIOS_TYPE,
|
2011-02-07 14:54:08 +00:00
|
|
|
QEMU_CAPS_VGA_NONE,
|
2011-09-21 08:25:29 +00:00
|
|
|
QEMU_CAPS_DRIVE_AIO,
|
2016-09-22 14:37:28 +00:00
|
|
|
QEMU_CAPS_PIIX3_USB_UHCI,
|
|
|
|
QEMU_CAPS_PIIX4_USB_UHCI,
|
|
|
|
QEMU_CAPS_USB_HUB,
|
2011-09-20 17:31:52 +00:00
|
|
|
QEMU_CAPS_NO_SHUTDOWN,
|
qemu: add new disk device='lun' for bus='virtio' & type='block'
In the past, generic SCSI commands issued from a guest to a virtio
disk were always passed through to the underlying disk by qemu, and
the kernel would also pass them on.
As a result of CVE-2011-4127 (see:
http://seclists.org/oss-sec/2011/q4/536), qemu now honors its
scsi=on|off device option for virtio-blk-pci (which enables/disables
passthrough of generic SCSI commands), and the kernel will only allow
the commands for physical devices (not for partitions or logical
volumes). The default behavior of qemu is still to allow sending
generic SCSI commands to physical disks that are presented to a guest
as virtio-blk-pci devices, but libvirt prefers to disable those
commands in the standard virtio block devices, enabling it only when
specifically requested (hopefully indicating that the requester
understands what they're asking for). For this purpose, a new libvirt
disk device type (device='lun') has been created.
device='lun' is identical to the default device='disk', except that:
1) It is only allowed if bus='virtio', type='block', and the qemu
version is "new enough" to support it ("new enough" == qemu 0.11 or
better), otherwise the domain will fail to start and a
CONFIG_UNSUPPORTED error will be logged).
2) The option "scsi=on" will be added to the -device arg to allow
SG_IO commands (if device !='lun', "scsi=off" will be added to the
-device arg so that SG_IO commands are specifically forbidden).
Guests which continue to use disk device='disk' (the default) will no
longer be able to use SG_IO commands on the disk; those that have
their disk device changed to device='lun' will still be able to use SG_IO
commands.
*docs/formatdomain.html.in - document the new device attribute value.
*docs/schemas/domaincommon.rng - allow it in the RNG
*tests/* - update the args of several existing tests to add scsi=off, and
add one new test that will test scsi=on.
*src/conf/domain_conf.c - update domain XML parser and formatter
*src/qemu/qemu_(command|driver|hotplug).c - treat
VIR_DOMAIN_DISK_DEVICE_LUN *almost* identically to
VIR_DOMAIN_DISK_DEVICE_DISK, except as indicated above.
Note that no support for this new device value was added to any
hypervisor drivers other than qemu, because it's unclear what it might
mean (if anything) to those drivers.
2012-01-05 03:48:38 +00:00
|
|
|
QEMU_CAPS_NO_ACPI,
|
2016-09-22 14:37:28 +00:00
|
|
|
QEMU_CAPS_SCSI_LSI,
|
|
|
|
QEMU_CAPS_VNC,
|
|
|
|
QEMU_CAPS_DEVICE_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_CIRRUS_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA,
|
|
|
|
QEMU_CAPS_DEVICE_USB_SERIAL,
|
|
|
|
QEMU_CAPS_DEVICE_USB_NET,
|
|
|
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC,
|
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE,
|
|
|
|
QEMU_CAPS_DEVICE_USB_KBD,
|
|
|
|
QEMU_CAPS_DEVICE_RTL8139,
|
|
|
|
QEMU_CAPS_DEVICE_E1000,
|
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET);
|
2011-02-08 14:22:39 +00:00
|
|
|
DO_TEST("qemu-kvm-0.13.0", 13000, 1, 0,
|
|
|
|
QEMU_CAPS_DRIVE_BOOT,
|
2011-09-22 19:33:47 +00:00
|
|
|
QEMU_CAPS_DRIVE_CACHE_UNSAFE,
|
2011-02-08 14:22:39 +00:00
|
|
|
QEMU_CAPS_KVM,
|
|
|
|
QEMU_CAPS_DRIVE_SERIAL,
|
|
|
|
QEMU_CAPS_MEM_PATH,
|
|
|
|
QEMU_CAPS_SDL,
|
|
|
|
QEMU_CAPS_ENABLE_KVM,
|
|
|
|
QEMU_CAPS_MONITOR_JSON,
|
|
|
|
QEMU_CAPS_NETDEV,
|
|
|
|
QEMU_CAPS_RTC,
|
2011-05-23 17:38:32 +00:00
|
|
|
QEMU_CAPS_VHOST_NET,
|
2011-02-08 14:22:39 +00:00
|
|
|
QEMU_CAPS_NO_HPET,
|
|
|
|
QEMU_CAPS_NO_KVM_PIT,
|
|
|
|
QEMU_CAPS_TDF,
|
|
|
|
QEMU_CAPS_PCI_CONFIGFD,
|
|
|
|
QEMU_CAPS_NODEFCONFIG,
|
|
|
|
QEMU_CAPS_BOOT_MENU,
|
|
|
|
QEMU_CAPS_FSDEV,
|
|
|
|
QEMU_CAPS_NESTING,
|
|
|
|
QEMU_CAPS_NAME_PROCESS,
|
|
|
|
QEMU_CAPS_SMBIOS_TYPE,
|
2011-02-07 14:54:08 +00:00
|
|
|
QEMU_CAPS_VGA_NONE,
|
|
|
|
QEMU_CAPS_DRIVE_AIO,
|
2011-09-02 12:56:50 +00:00
|
|
|
QEMU_CAPS_PCI_MULTIFUNCTION,
|
|
|
|
QEMU_CAPS_PIIX3_USB_UHCI,
|
|
|
|
QEMU_CAPS_PIIX4_USB_UHCI,
|
|
|
|
QEMU_CAPS_VT82C686B_USB_UHCI,
|
2011-09-02 14:20:40 +00:00
|
|
|
QEMU_CAPS_PCI_OHCI,
|
2011-09-21 08:25:29 +00:00
|
|
|
QEMU_CAPS_USB_HUB,
|
2011-09-20 17:31:52 +00:00
|
|
|
QEMU_CAPS_NO_SHUTDOWN,
|
qemu: add new disk device='lun' for bus='virtio' & type='block'
In the past, generic SCSI commands issued from a guest to a virtio
disk were always passed through to the underlying disk by qemu, and
the kernel would also pass them on.
As a result of CVE-2011-4127 (see:
http://seclists.org/oss-sec/2011/q4/536), qemu now honors its
scsi=on|off device option for virtio-blk-pci (which enables/disables
passthrough of generic SCSI commands), and the kernel will only allow
the commands for physical devices (not for partitions or logical
volumes). The default behavior of qemu is still to allow sending
generic SCSI commands to physical disks that are presented to a guest
as virtio-blk-pci devices, but libvirt prefers to disable those
commands in the standard virtio block devices, enabling it only when
specifically requested (hopefully indicating that the requester
understands what they're asking for). For this purpose, a new libvirt
disk device type (device='lun') has been created.
device='lun' is identical to the default device='disk', except that:
1) It is only allowed if bus='virtio', type='block', and the qemu
version is "new enough" to support it ("new enough" == qemu 0.11 or
better), otherwise the domain will fail to start and a
CONFIG_UNSUPPORTED error will be logged).
2) The option "scsi=on" will be added to the -device arg to allow
SG_IO commands (if device !='lun', "scsi=off" will be added to the
-device arg so that SG_IO commands are specifically forbidden).
Guests which continue to use disk device='disk' (the default) will no
longer be able to use SG_IO commands on the disk; those that have
their disk device changed to device='lun' will still be able to use SG_IO
commands.
*docs/formatdomain.html.in - document the new device attribute value.
*docs/schemas/domaincommon.rng - allow it in the RNG
*tests/* - update the args of several existing tests to add scsi=off, and
add one new test that will test scsi=on.
*src/conf/domain_conf.c - update domain XML parser and formatter
*src/qemu/qemu_(command|driver|hotplug).c - treat
VIR_DOMAIN_DISK_DEVICE_LUN *almost* identically to
VIR_DOMAIN_DISK_DEVICE_DISK, except as indicated above.
Note that no support for this new device value was added to any
hypervisor drivers other than qemu, because it's unclear what it might
mean (if anything) to those drivers.
2012-01-05 03:48:38 +00:00
|
|
|
QEMU_CAPS_NO_ACPI,
|
2012-10-19 19:40:52 +00:00
|
|
|
QEMU_CAPS_SCSI_LSI,
|
2012-12-14 07:06:31 +00:00
|
|
|
QEMU_CAPS_VNC,
|
|
|
|
QEMU_CAPS_DEVICE_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_CIRRUS_VGA,
|
2013-01-03 06:57:25 +00:00
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA,
|
2013-01-03 07:13:05 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_SERIAL,
|
2013-03-07 11:03:41 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_NET,
|
2013-05-03 18:07:21 +00:00
|
|
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
2013-08-23 10:38:10 +00:00
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC,
|
2014-02-17 10:17:55 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_KBD,
|
qemu: add host-pci-multidomain capability
Quite a long time ago, (apparently between qemu 0.12 and 0.13) qemu
quietly began supporting the optional specification of a domain in the
host-side address of all pci passthrough commands (by simply
prepending it to the bus:slot.function format, as
"dddd:bb:ss.f"). Since machines with multiple PCI domains are very
rare, this never came up in practice, so libvirt was never updated to
support it.
This patch takes the first step to supporting specification of a non-0
domain in the host-side address of PCI devices being assigned to a
domain, by adding a capability bit to indicate support
"QEMU_CAPS_HOST_PCI_MULTIDOMAIN", and detect it. Since this support
was added in a version prior to the minimum version required for
QMP-style capabilities detection, the capability is always enabled for
any qemu that uses QMP for capabilities detection. For older qemus,
the only clue that a domain can be specified in the host pci address
is the presence of the string "[seg:]" in the help string for
-pcidevice. (Ironically, libvirt will not be modified to support
specification of domain for -pcidevice, since any qemu new enough for
us to care about also supports "-device pci-assign" or "-device
vfio-pci", which are greatly preferred).
2014-04-29 15:11:45 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE,
|
2014-08-22 10:47:02 +00:00
|
|
|
QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
|
2015-09-04 14:23:46 +00:00
|
|
|
QEMU_CAPS_DEVICE_IVSHMEM,
|
2015-09-04 14:40:37 +00:00
|
|
|
QEMU_CAPS_DEVICE_RTL8139,
|
2015-09-01 12:38:19 +00:00
|
|
|
QEMU_CAPS_DEVICE_E1000,
|
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET);
|
2011-12-02 20:20:15 +00:00
|
|
|
DO_TEST("qemu-1.0", 1000000, 0, 0,
|
|
|
|
QEMU_CAPS_DRIVE_CACHE_UNSAFE,
|
|
|
|
QEMU_CAPS_DRIVE_SERIAL,
|
|
|
|
QEMU_CAPS_MEM_PATH,
|
|
|
|
QEMU_CAPS_SDL,
|
|
|
|
QEMU_CAPS_ENABLE_KVM,
|
|
|
|
QEMU_CAPS_MONITOR_JSON,
|
|
|
|
QEMU_CAPS_NETDEV,
|
|
|
|
QEMU_CAPS_RTC,
|
|
|
|
QEMU_CAPS_VHOST_NET,
|
|
|
|
QEMU_CAPS_NO_HPET,
|
|
|
|
QEMU_CAPS_NODEFCONFIG,
|
|
|
|
QEMU_CAPS_BOOT_MENU,
|
|
|
|
QEMU_CAPS_FSDEV,
|
|
|
|
QEMU_CAPS_NAME_PROCESS,
|
|
|
|
QEMU_CAPS_SMBIOS_TYPE,
|
|
|
|
QEMU_CAPS_SPICE,
|
|
|
|
QEMU_CAPS_VGA_NONE,
|
|
|
|
QEMU_CAPS_BOOTINDEX,
|
|
|
|
QEMU_CAPS_HDA_DUPLEX,
|
|
|
|
QEMU_CAPS_DRIVE_AIO,
|
|
|
|
QEMU_CAPS_CCID_EMULATED,
|
|
|
|
QEMU_CAPS_CCID_PASSTHRU,
|
|
|
|
QEMU_CAPS_CHARDEV_SPICEVMC,
|
|
|
|
QEMU_CAPS_VIRTIO_TX_ALG,
|
|
|
|
QEMU_CAPS_PCI_MULTIFUNCTION,
|
|
|
|
QEMU_CAPS_VIRTIO_IOEVENTFD,
|
|
|
|
QEMU_CAPS_SGA,
|
|
|
|
QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
|
|
|
|
QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
|
|
|
|
QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC,
|
|
|
|
QEMU_CAPS_PIIX3_USB_UHCI,
|
|
|
|
QEMU_CAPS_PIIX4_USB_UHCI,
|
|
|
|
QEMU_CAPS_USB_EHCI,
|
|
|
|
QEMU_CAPS_ICH9_USB_EHCI1,
|
|
|
|
QEMU_CAPS_VT82C686B_USB_UHCI,
|
|
|
|
QEMU_CAPS_PCI_OHCI,
|
|
|
|
QEMU_CAPS_USB_HUB,
|
|
|
|
QEMU_CAPS_NO_SHUTDOWN,
|
2011-12-20 01:08:29 +00:00
|
|
|
QEMU_CAPS_ICH9_AHCI,
|
2011-12-22 10:00:05 +00:00
|
|
|
QEMU_CAPS_NO_ACPI,
|
qemu: add new disk device='lun' for bus='virtio' & type='block'
In the past, generic SCSI commands issued from a guest to a virtio
disk were always passed through to the underlying disk by qemu, and
the kernel would also pass them on.
As a result of CVE-2011-4127 (see:
http://seclists.org/oss-sec/2011/q4/536), qemu now honors its
scsi=on|off device option for virtio-blk-pci (which enables/disables
passthrough of generic SCSI commands), and the kernel will only allow
the commands for physical devices (not for partitions or logical
volumes). The default behavior of qemu is still to allow sending
generic SCSI commands to physical disks that are presented to a guest
as virtio-blk-pci devices, but libvirt prefers to disable those
commands in the standard virtio block devices, enabling it only when
specifically requested (hopefully indicating that the requester
understands what they're asking for). For this purpose, a new libvirt
disk device type (device='lun') has been created.
device='lun' is identical to the default device='disk', except that:
1) It is only allowed if bus='virtio', type='block', and the qemu
version is "new enough" to support it ("new enough" == qemu 0.11 or
better), otherwise the domain will fail to start and a
CONFIG_UNSUPPORTED error will be logged).
2) The option "scsi=on" will be added to the -device arg to allow
SG_IO commands (if device !='lun', "scsi=off" will be added to the
-device arg so that SG_IO commands are specifically forbidden).
Guests which continue to use disk device='disk' (the default) will no
longer be able to use SG_IO commands on the disk; those that have
their disk device changed to device='lun' will still be able to use SG_IO
commands.
*docs/formatdomain.html.in - document the new device attribute value.
*docs/schemas/domaincommon.rng - allow it in the RNG
*tests/* - update the args of several existing tests to add scsi=off, and
add one new test that will test scsi=on.
*src/conf/domain_conf.c - update domain XML parser and formatter
*src/qemu/qemu_(command|driver|hotplug).c - treat
VIR_DOMAIN_DISK_DEVICE_LUN *almost* identically to
VIR_DOMAIN_DISK_DEVICE_DISK, except as indicated above.
Note that no support for this new device value was added to any
hypervisor drivers other than qemu, because it's unclear what it might
mean (if anything) to those drivers.
2012-01-05 03:48:38 +00:00
|
|
|
QEMU_CAPS_FSDEV_READONLY,
|
|
|
|
QEMU_CAPS_VIRTIO_BLK_SCSI,
|
2012-03-12 14:19:56 +00:00
|
|
|
QEMU_CAPS_FSDEV_WRITEOUT,
|
2012-04-17 09:08:05 +00:00
|
|
|
QEMU_CAPS_SCSI_BLOCK,
|
2012-04-17 09:16:52 +00:00
|
|
|
QEMU_CAPS_SCSI_CD,
|
2012-08-08 06:25:24 +00:00
|
|
|
QEMU_CAPS_IDE_CD,
|
2012-08-29 15:48:31 +00:00
|
|
|
QEMU_CAPS_SCSI_LSI,
|
2012-10-19 19:40:52 +00:00
|
|
|
QEMU_CAPS_BLOCKIO,
|
2012-12-14 07:06:31 +00:00
|
|
|
QEMU_CAPS_VNC,
|
2013-03-29 05:22:46 +00:00
|
|
|
QEMU_CAPS_MACHINE_OPT,
|
2012-12-14 07:06:31 +00:00
|
|
|
QEMU_CAPS_DEVICE_QXL,
|
|
|
|
QEMU_CAPS_DEVICE_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_CIRRUS_VGA,
|
2013-01-03 06:57:25 +00:00
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA,
|
2013-01-03 07:13:05 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_SERIAL,
|
2013-05-03 18:07:21 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_NET,
|
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC,
|
2013-08-23 10:38:10 +00:00
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
|
2014-02-17 10:17:55 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_KBD,
|
2014-08-22 11:42:46 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE,
|
2014-08-22 10:47:02 +00:00
|
|
|
QEMU_CAPS_SPLASH_TIMEOUT,
|
2015-06-17 17:13:28 +00:00
|
|
|
QEMU_CAPS_DEVICE_IVSHMEM,
|
2015-06-16 18:54:21 +00:00
|
|
|
QEMU_CAPS_DEVICE_IOH3420,
|
2015-06-17 18:24:29 +00:00
|
|
|
QEMU_CAPS_DEVICE_X3130_UPSTREAM,
|
2015-09-04 14:23:46 +00:00
|
|
|
QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
|
2015-09-04 14:40:37 +00:00
|
|
|
QEMU_CAPS_DEVICE_RTL8139,
|
2015-09-01 12:38:19 +00:00
|
|
|
QEMU_CAPS_DEVICE_E1000,
|
2016-07-05 12:35:27 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET,
|
|
|
|
QEMU_CAPS_DISPLAY);
|
2012-06-05 13:34:09 +00:00
|
|
|
DO_TEST("qemu-1.1.0", 1001000, 0, 0,
|
2012-04-26 10:11:49 +00:00
|
|
|
QEMU_CAPS_DRIVE_CACHE_UNSAFE,
|
|
|
|
QEMU_CAPS_DRIVE_SERIAL,
|
|
|
|
QEMU_CAPS_MEM_PATH,
|
|
|
|
QEMU_CAPS_SDL,
|
|
|
|
QEMU_CAPS_ENABLE_KVM,
|
|
|
|
QEMU_CAPS_MONITOR_JSON,
|
|
|
|
QEMU_CAPS_NETDEV,
|
|
|
|
QEMU_CAPS_RTC,
|
|
|
|
QEMU_CAPS_VHOST_NET,
|
|
|
|
QEMU_CAPS_NO_HPET,
|
|
|
|
QEMU_CAPS_NODEFCONFIG,
|
|
|
|
QEMU_CAPS_BOOT_MENU,
|
|
|
|
QEMU_CAPS_FSDEV,
|
|
|
|
QEMU_CAPS_NAME_PROCESS,
|
|
|
|
QEMU_CAPS_SMBIOS_TYPE,
|
|
|
|
QEMU_CAPS_SPICE,
|
|
|
|
QEMU_CAPS_VGA_NONE,
|
|
|
|
QEMU_CAPS_BOOTINDEX,
|
|
|
|
QEMU_CAPS_HDA_DUPLEX,
|
|
|
|
QEMU_CAPS_DRIVE_AIO,
|
|
|
|
QEMU_CAPS_CCID_EMULATED,
|
|
|
|
QEMU_CAPS_CCID_PASSTHRU,
|
|
|
|
QEMU_CAPS_CHARDEV_SPICEVMC,
|
|
|
|
QEMU_CAPS_VIRTIO_TX_ALG,
|
|
|
|
QEMU_CAPS_PCI_MULTIFUNCTION,
|
|
|
|
QEMU_CAPS_VIRTIO_IOEVENTFD,
|
|
|
|
QEMU_CAPS_SGA,
|
|
|
|
QEMU_CAPS_VIRTIO_BLK_EVENT_IDX,
|
|
|
|
QEMU_CAPS_VIRTIO_NET_EVENT_IDX,
|
|
|
|
QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC,
|
|
|
|
QEMU_CAPS_PIIX3_USB_UHCI,
|
|
|
|
QEMU_CAPS_PIIX4_USB_UHCI,
|
|
|
|
QEMU_CAPS_USB_EHCI,
|
|
|
|
QEMU_CAPS_ICH9_USB_EHCI1,
|
|
|
|
QEMU_CAPS_VT82C686B_USB_UHCI,
|
|
|
|
QEMU_CAPS_PCI_OHCI,
|
|
|
|
QEMU_CAPS_USB_HUB,
|
|
|
|
QEMU_CAPS_NO_SHUTDOWN,
|
|
|
|
QEMU_CAPS_ICH9_AHCI,
|
|
|
|
QEMU_CAPS_NO_ACPI,
|
|
|
|
QEMU_CAPS_FSDEV_READONLY,
|
|
|
|
QEMU_CAPS_VIRTIO_BLK_SCSI,
|
|
|
|
QEMU_CAPS_DRIVE_COPY_ON_READ,
|
|
|
|
QEMU_CAPS_FSDEV_WRITEOUT,
|
|
|
|
QEMU_CAPS_DRIVE_IOTUNE,
|
|
|
|
QEMU_CAPS_SCSI_DISK_CHANNEL,
|
|
|
|
QEMU_CAPS_SCSI_BLOCK,
|
|
|
|
QEMU_CAPS_SCSI_CD,
|
|
|
|
QEMU_CAPS_IDE_CD,
|
2012-05-15 22:55:08 +00:00
|
|
|
QEMU_CAPS_NO_USER_CONFIG,
|
2012-06-21 13:45:25 +00:00
|
|
|
QEMU_CAPS_HDA_MICRO,
|
2012-08-03 20:33:05 +00:00
|
|
|
QEMU_CAPS_NEC_USB_XHCI,
|
2012-08-08 06:25:24 +00:00
|
|
|
QEMU_CAPS_NETDEV_BRIDGE,
|
|
|
|
QEMU_CAPS_SCSI_LSI,
|
2013-03-14 18:32:24 +00:00
|
|
|
QEMU_CAPS_VIRTIO_SCSI,
|
2012-10-19 19:40:52 +00:00
|
|
|
QEMU_CAPS_BLOCKIO,
|
2012-12-14 07:06:31 +00:00
|
|
|
QEMU_CAPS_VNC,
|
2013-03-29 05:22:46 +00:00
|
|
|
QEMU_CAPS_MACHINE_OPT,
|
2012-12-14 07:06:31 +00:00
|
|
|
QEMU_CAPS_DEVICE_QXL,
|
|
|
|
QEMU_CAPS_DEVICE_VGA,
|
|
|
|
QEMU_CAPS_DEVICE_CIRRUS_VGA,
|
2013-01-03 06:57:25 +00:00
|
|
|
QEMU_CAPS_DEVICE_VMWARE_SVGA,
|
2013-01-03 07:13:05 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_SERIAL,
|
2013-03-14 04:49:43 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_NET,
|
2013-03-22 13:52:25 +00:00
|
|
|
QEMU_CAPS_DTB,
|
2013-03-07 11:03:41 +00:00
|
|
|
QEMU_CAPS_IPV6_MIGRATION,
|
2013-05-03 18:07:21 +00:00
|
|
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC,
|
2013-05-21 14:31:47 +00:00
|
|
|
QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
|
2013-08-23 10:38:10 +00:00
|
|
|
QEMU_CAPS_VNC_SHARE_POLICY,
|
2014-02-17 10:17:55 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_KBD,
|
2014-07-24 15:32:31 +00:00
|
|
|
QEMU_CAPS_DEVICE_USB_STORAGE,
|
2014-08-22 11:42:46 +00:00
|
|
|
QEMU_CAPS_OBJECT_USB_AUDIO,
|
2014-08-22 10:47:02 +00:00
|
|
|
QEMU_CAPS_SPLASH_TIMEOUT,
|
2015-06-17 17:13:28 +00:00
|
|
|
QEMU_CAPS_DEVICE_IVSHMEM,
|
2015-06-16 18:54:21 +00:00
|
|
|
QEMU_CAPS_DEVICE_IOH3420,
|
2015-06-17 18:24:29 +00:00
|
|
|
QEMU_CAPS_DEVICE_X3130_UPSTREAM,
|
2015-09-04 14:23:46 +00:00
|
|
|
QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
|
2015-09-04 14:40:37 +00:00
|
|
|
QEMU_CAPS_DEVICE_RTL8139,
|
2015-09-01 12:38:19 +00:00
|
|
|
QEMU_CAPS_DEVICE_E1000,
|
2016-07-05 12:35:27 +00:00
|
|
|
QEMU_CAPS_DEVICE_VIRTIO_NET,
|
|
|
|
QEMU_CAPS_DISPLAY);
|
2014-11-12 15:49:59 +00:00
|
|
|
DO_TEST_FULL("qemu-1.2.0", 1002000, 0, 0, VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
QEMU_CAPS_LAST);
|
|
|
|
DO_TEST_FULL("qemu-kvm-1.2.0", 1002000, 1, 0, VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
QEMU_CAPS_LAST);
|
2009-06-11 14:17:42 +00:00
|
|
|
|
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2017-03-29 14:45:42 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|
2009-06-11 14:17:42 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2011-07-08 23:24:44 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
}
|
2009-06-11 14:17:42 +00:00
|
|
|
|
|
|
|
#endif /* WITH_QEMU */
|