[libvirt] [PATCH v2 0/2] Couple of hotplug cleanups
by John Ferlan
Necromancing some old branches...
v1: https://www.redhat.com/archives/libvir-list/2017-October/msg00930.html
Changes since v1 - beef up commit messages and drop patches 3 & 4 as
that's a bit more involved and Jan seemed to imply he eventually may
send patches dealing with the same thing - so I'll wait to see those.
John Ferlan (2):
conf,qemu: Check for NULL addrs in virDomainUSBAddressRelease
conf,qemu: Check for NULL addrs in virDomainUSBAddressEnsure
src/conf/domain_addr.c | 5 ++++-
src/conf/domain_addr.h | 4 ++--
src/qemu/qemu_domain_address.c | 7 ++-----
src/qemu/qemu_hotplug.c | 31 ++++++++++---------------------
4 files changed, 18 insertions(+), 29 deletions(-)
--
2.13.6
6 years, 10 months
[libvirt] [PATCH v4 0/5] qemu: use arp table of host to get the
by Chen Hanxiao
introduce VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP to get ip address
of VM from the output of /proc/net/arp
Chen Hanxiao (5):
util: introduce virNetlinkGetNeighbor to get neighbor table entry
util: introduce helper to parse message from RTM_GETNEIGH query
qemu: introduce qemuARPGetInterfaces to get IP from host's arp table
virsh: add --source arp to domifaddr
news: qemu: use arp table of host to get the IP address of guests
docs/news.xml | 9 ++
include/libvirt/libvirt-domain.h | 1 +
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/libvirt-domain.c | 7 ++
src/libvirt_private.syms | 6 ++
src/qemu/qemu_driver.c | 72 ++++++++++++++++
src/util/virarptable.c | 182 +++++++++++++++++++++++++++++++++++++++
src/util/virarptable.h | 47 ++++++++++
src/util/virnetlink.c | 82 ++++++++++++++++++
src/util/virnetlink.h | 2 +
tools/virsh-domain-monitor.c | 2 +
tools/virsh.pod | 7 +-
13 files changed, 416 insertions(+), 3 deletions(-)
create mode 100644 src/util/virarptable.c
create mode 100644 src/util/virarptable.h
--
2.14.3
6 years, 10 months
[libvirt] [PATCH] libxl: add support for specifying clock offset and adjustment
by Jim Fehlig
libxl supports setting the domain real time clock to local time or
UTC via the localtime field of libxl_domain_build_info. Adjustment
of the clock is also supported via the rtc_timeoffset field. The
libvirt libxl driver has never supported these settings, instead
relying on libxl's default of a UTC real time clock with adjustment
set to 0.
There is at least one user that would like the ability to change
the defaults
https://www.redhat.com/archives/libvirt-users/2018-February/msg00059.html
Add support for specifying a local time clock and for specifying an
adjustment for both local time and UTC clocks. Add a test case to
verify the XML to libxl_domain_config conversion.
Local time clock and clock adjustment is already supported by the
XML <-> xl.cfg converter. What is missing is an explicit test for
the conversion. There are plenty of existing tests that all use UTC
with 0 adjustment. Hijack test-fullvirt-tsc-timer to test a local
time clock with 1 hour adjustment.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_conf.c | 35 +++++++--
.../libxlxml2domconfigdata/variable-clock-hvm.json | 91 ++++++++++++++++++++++
.../libxlxml2domconfigdata/variable-clock-hvm.xml | 36 +++++++++
tests/libxlxml2domconfigtest.c | 1 +
tests/xlconfigdata/test-fullvirt-tsc-timer.cfg | 4 +-
tests/xlconfigdata/test-fullvirt-tsc-timer.xml | 2 +-
6 files changed, 160 insertions(+), 9 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 0c5de344d..39ae709c7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -274,6 +274,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
virCapsPtr caps,
libxl_domain_config *d_config)
{
+ virDomainClockDef clock = def->clock;
libxl_domain_build_info *b_info = &d_config->b_info;
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
size_t i;
@@ -293,10 +294,32 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
for (i = 0; i < virDomainDefGetVcpus(def); i++)
libxl_bitmap_set((&b_info->avail_vcpus), i);
- for (i = 0; i < def->clock.ntimers; i++) {
- switch ((virDomainTimerNameType) def->clock.timers[i]->name) {
+ switch (clock.offset) {
+ case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
+ if (clock.data.variable.basis == VIR_DOMAIN_CLOCK_BASIS_LOCALTIME)
+ libxl_defbool_set(&b_info->localtime, true);
+ b_info->rtc_timeoffset = clock.data.variable.adjustment;
+ break;
+
+ case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
+ libxl_defbool_set(&b_info->localtime, true);
+ break;
+
+ /* Nothing to do since UTC is the default in libxl */
+ case VIR_DOMAIN_CLOCK_OFFSET_UTC:
+ break;
+
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported clock offset '%s'"),
+ virDomainClockOffsetTypeToString(clock.offset));
+ return -1;
+ }
+
+ for (i = 0; i < clock.ntimers; i++) {
+ switch ((virDomainTimerNameType) clock.timers[i]->name) {
case VIR_DOMAIN_TIMER_NAME_TSC:
- switch (def->clock.timers[i]->mode) {
+ switch (clock.timers[i]->mode) {
case VIR_DOMAIN_TIMER_MODE_NATIVE:
b_info->tsc_mode = LIBXL_TSC_MODE_NATIVE;
break;
@@ -315,10 +338,10 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
if (!hvm) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported timer type (name) '%s'"),
- virDomainTimerNameTypeToString(def->clock.timers[i]->name));
+ virDomainTimerNameTypeToString(clock.timers[i]->name));
return -1;
}
- if (def->clock.timers[i]->present == 1)
+ if (clock.timers[i]->present == 1)
libxl_defbool_set(&b_info->u.hvm.hpet, 1);
break;
@@ -329,7 +352,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
case VIR_DOMAIN_TIMER_NAME_PIT:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported timer type (name) '%s'"),
- virDomainTimerNameTypeToString(def->clock.timers[i]->name));
+ virDomainTimerNameTypeToString(clock.timers[i]->name));
return -1;
case VIR_DOMAIN_TIMER_NAME_LAST:
diff --git a/tests/libxlxml2domconfigdata/variable-clock-hvm.json b/tests/libxlxml2domconfigdata/variable-clock-hvm.json
new file mode 100644
index 000000000..49d0a4330
--- /dev/null
+++ b/tests/libxlxml2domconfigdata/variable-clock-hvm.json
@@ -0,0 +1,91 @@
+{
+ "c_info": {
+ "type": "hvm",
+ "name": "test-hvm",
+ "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b"
+ },
+ "b_info": {
+ "max_vcpus": 4,
+ "avail_vcpus": [
+ 0,
+ 1,
+ 2,
+ 3
+ ],
+ "max_memkb": 1048576,
+ "target_memkb": 1048576,
+ "video_memkb": 8192,
+ "shadow_memkb": 12288,
+ "rtc_timeoffset": 3600,
+ "localtime": "True",
+ "device_model_version": "qemu_xen",
+ "device_model": "/bin/true",
+ "sched_params": {
+ "weight": 1000
+ },
+ "type.hvm": {
+ "pae": "True",
+ "apic": "True",
+ "acpi": "True",
+ "vga": {
+ "kind": "cirrus"
+ },
+ "vnc": {
+ "enable": "True",
+ "listen": "0.0.0.0",
+ "findunused": "False"
+ },
+ "sdl": {
+ "enable": "False"
+ },
+ "spice": {
+
+ },
+ "boot": "c",
+ "rdm": {
+
+ }
+ },
+ "arch_arm": {
+
+ }
+ },
+ "disks": [
+ {
+ "pdev_path": "/var/lib/xen/images/test-hvm.img",
+ "vdev": "hda",
+ "backend": "qdisk",
+ "format": "raw",
+ "removable": 1,
+ "readwrite": 1
+ }
+ ],
+ "nics": [
+ {
+ "devid": 0,
+ "mac": "00:16:3e:66:12:b4",
+ "bridge": "br0",
+ "script": "/etc/xen/scripts/vif-bridge",
+ "nictype": "vif_ioemu"
+ }
+ ],
+ "vfbs": [
+ {
+ "devid": -1,
+ "vnc": {
+ "enable": "True",
+ "listen": "0.0.0.0",
+ "findunused": "False"
+ },
+ "sdl": {
+ "enable": "False"
+ }
+ }
+ ],
+ "vkbs": [
+ {
+ "devid": -1
+ }
+ ],
+ "on_reboot": "restart"
+}
diff --git a/tests/libxlxml2domconfigdata/variable-clock-hvm.xml b/tests/libxlxml2domconfigdata/variable-clock-hvm.xml
new file mode 100644
index 000000000..608788779
--- /dev/null
+++ b/tests/libxlxml2domconfigdata/variable-clock-hvm.xml
@@ -0,0 +1,36 @@
+<domain type='xen'>
+ <name>test-hvm</name>
+ <description>None</description>
+ <uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>4</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <clock offset='localtime' adjustment='3600'/>
+ <os>
+ <type>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <apic/>
+ <acpi/>
+ <pae/>
+ </features>
+ <devices>
+ <emulator>/bin/true</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu'/>
+ <source file='/var/lib/xen/images/test-hvm.img'/>
+ <target dev='hda'/>
+ </disk>
+ <interface type='bridge'>
+ <source bridge='br0'/>
+ <mac address='00:16:3e:66:12:b4'/>
+ <script path='/etc/xen/scripts/vif-bridge'/>
+ </interface>
+ <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
+ </devices>
+</domain>
diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
index bd4c3af5a..be3e34944 100644
--- a/tests/libxlxml2domconfigtest.c
+++ b/tests/libxlxml2domconfigtest.c
@@ -188,6 +188,7 @@ mymain(void)
DO_TEST("basic-pv");
DO_TEST("basic-hvm");
+ DO_TEST("variable-clock-hvm");
DO_TEST("moredevs-hvm");
DO_TEST("vnuma-hvm");
DO_TEST("multiple-ip");
diff --git a/tests/xlconfigdata/test-fullvirt-tsc-timer.cfg b/tests/xlconfigdata/test-fullvirt-tsc-timer.cfg
index 609c0fd5a..587d3461f 100644
--- a/tests/xlconfigdata/test-fullvirt-tsc-timer.cfg
+++ b/tests/xlconfigdata/test-fullvirt-tsc-timer.cfg
@@ -9,8 +9,8 @@ apic = 1
hap = 0
viridian = 0
tsc_mode = "native"
-rtc_timeoffset = 0
-localtime = 0
+rtc_timeoffset = 3600
+localtime = 1
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
diff --git a/tests/xlconfigdata/test-fullvirt-tsc-timer.xml b/tests/xlconfigdata/test-fullvirt-tsc-timer.xml
index bedbe8e0e..0816f96f3 100644
--- a/tests/xlconfigdata/test-fullvirt-tsc-timer.xml
+++ b/tests/xlconfigdata/test-fullvirt-tsc-timer.xml
@@ -15,7 +15,7 @@
<pae/>
<hap state='off'/>
</features>
- <clock offset='variable' adjustment='0' basis='utc'>
+ <clock offset='variable' adjustment='3600' basis='localtime'>
<timer name='tsc' present='yes' mode='native'/>
</clock>
<on_poweroff>destroy</on_poweroff>
--
2.16.1
6 years, 10 months
[libvirt] [PATCH v2 00/14] Enforce presence of all switch enum cases
by Daniel P. Berrangé
This is the same as the previous series, but with standardized error
reporting macro to get consistent error messages.
This is just the first part of the previous series. The second part is
much more work to convert to this new error reporting macro, so i'll
drip-feed the rest for review over next few days...
Daniel P. Berrangé (14):
util: add a virReportEnumRangeError for bad value reporting
util: handle missing switch enum cases
conf: handle missing switch enum cases
esx: handle missing switch enum cases
hyperv: handle missing switch enum cases
libxl: handle missing switch enum cases
lxc: handle missing switch enum cases
nwfilter: handle missing switch enum cases
qemu: handle missing switch enum cases
rpc: handle missing switch enum cases
security: handle missing switch enum cases
xen: handle missing switch enum cases
tools: handle missing switch enum cases
m4: enforce that all enum cases are listed in switch statements
m4/virt-compile-warnings.m4 | 7 +++--
src/conf/domain_audit.c | 1 +
src/conf/domain_conf.c | 46 +++++++++++++++++++++++++++----
src/conf/nwfilter_conf.c | 31 ++++++++++++++++++++-
src/conf/nwfilter_conf.h | 4 +--
src/esx/esx_driver.c | 1 +
src/esx/esx_vi.c | 11 +++++---
src/esx/esx_vi_types.c | 9 +++---
src/hyperv/hyperv_driver.c | 18 ++++++++++--
src/libxl/libxl_driver.c | 2 +-
src/lxc/lxc_container.c | 8 +++---
src/lxc/lxc_controller.c | 8 +++++-
src/lxc/lxc_driver.c | 38 ++++++++++++++++++++++---
src/nwfilter/nwfilter_ebiptables_driver.c | 17 ++++++++----
src/nwfilter/nwfilter_learnipaddr.c | 6 +++-
src/qemu/qemu_command.c | 26 +++++++++++------
src/qemu/qemu_domain.c | 21 ++++++++++++++
src/qemu/qemu_driver.c | 25 +++++++++++------
src/qemu/qemu_hotplug.c | 33 ++++++++++++++++++----
src/qemu/qemu_migration.c | 11 +++++++-
src/qemu/qemu_process.c | 2 ++
src/rpc/virnetclient.c | 2 ++
src/rpc/virnetclientprogram.c | 1 +
src/rpc/virnetserverprogram.c | 4 +++
src/security/security_driver.c | 1 +
src/util/virconf.c | 11 +++++++-
src/util/virerror.h | 9 +++++-
src/util/virfirewall.c | 6 ++--
src/util/virlog.c | 9 +++++-
src/util/virnetdevvportprofile.c | 10 ++++++-
src/vmx/vmx.c | 26 +++++++++++++++--
src/xenconfig/xen_common.c | 18 ++++++++++--
src/xenconfig/xen_xl.c | 7 ++++-
tools/virt-host-validate-qemu.c | 3 +-
34 files changed, 359 insertions(+), 73 deletions(-)
--
2.14.3
6 years, 10 months
[libvirt] [PATCH v2 0/2] Support network stats for hostdev(SR-IOV) in Switchdev mode
by Jai Singh Rana
With availability of switchdev model in linux, it is possible to capture
stats for hostdev SR-IOV VFs using its VF representor interface name on
host for nics supporting switchdev model.
These stats are supported by adding helper APIs for getting VF
Representor name based on BDF info in 'hostdev' and querying required
net sysfs entries on host. These helper APIs are then used in
qemu_driver to get the hostdev interface stats for pci SR-IOV device.
[1] https://www.kernel.org/doc/Documentation/networking/switchdev.txt
Jai Singh Rana (2):
util: Add helper APIs to get/verify VF Representor name
qemu: conf: Network stats support for hostdev VF Representor
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/conf/domain_conf.c | 7 ++
src/libvirt_private.syms | 5 +
src/qemu/qemu_driver.c | 34 ++++++-
src/util/virhostdev.c | 11 +++
src/util/virhostdev.h | 6 ++
src/util/virnetdevhostdev.c | 224 ++++++++++++++++++++++++++++++++++++++++++++
src/util/virnetdevhostdev.h | 33 +++++++
9 files changed, 318 insertions(+), 4 deletions(-)
create mode 100644 src/util/virnetdevhostdev.c
create mode 100644 src/util/virnetdevhostdev.h
--
2.13.6
6 years, 10 months
[libvirt] [PATCH] Add Marcin Juszkiewicz to Planet Virt-Tools
by Marcin Juszkiewicz
Signed-off-by: Marcin Juszkiewicz <marcin(a)juszkiewicz.com.pl>
---
updater/virt-tools/config.ini | 3 +++
1 file changed, 3 insertions(+)
diff --git a/updater/virt-tools/config.ini b/updater/virt-tools/config.ini
index d47e82f..a56d3b7 100644
--- a/updater/virt-tools/config.ini
+++ b/updater/virt-tools/config.ini
@@ -173,3 +173,6 @@ name = Eduardo Otubo
face = otubo.png
facewidth = 80
faceheight = 80
+
+[https://marcin.juszkiewicz.com.pl/tag/virtualization/feed/]
+name = Marcin Juszkiewicz
--
2.14.3
6 years, 10 months
[libvirt] [PATCH glib] m4: disable gcc8 -Wcast-function-type warnings from -Wextra
by Daniel P. Berrangé
The -Wextra flag bundle gained a new warning -Wcast-function-type.
This complains if you cast between two function prototypes where
the number of parameters or their data types are not compatible.
Unfortunately we need such "bad" function casts for our event
callbacks. It is possible to silence the warning by first casting
to the generic "void (*)(void)" function prototype, but that is
rather ugly to add throughout libvirt code.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed as a CI build fix
m4/virt-compile-warnings.m4 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 0cf67fa..cbd9e0c 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -151,6 +151,9 @@ AC_DEFUN([LIBVIRT_GLIB_COMPILE_WARNINGS],[
# that one off, so we need to manually enable this again
wantwarn="$wantwarn -Wjump-misses-init"
+ # We do "bad" function casts all the time for event callbacks
+ wantwarn="$wantwarn -Wno-cast-function-type"
+
# GNULIB turns on -Wformat=2 which implies -Wformat-nonliteral,
# so we need to manually re-exclude it. Also, older gcc 4.2
# added an implied ATTRIBUTE_NONNULL on any parameter marked
--
2.14.3
6 years, 10 months
[libvirt] [PATCH v2 00/42] Fix build with gcc8 and switch() robustness
by Daniel P. Berrangé
This started off as a simple fix to deal with gcc8. After shearing a few
hundred yaks, it is a now a 42 patch series :-)
The crux of the issue is/was that gcc8 reports various problems wrt
fallthrough for some switch statements. These were indeed bugs in
libvirt which the first patch fixes. What this highlighted, however,
was that relying on only listing valid enum constant names in switch
case statements is unsafe. Nothing at all prevents you from assigning
an invalid integer value to a variable that is treated as an enum.
Thus to be safe we should have a default: for every switch. Adding
this causes us to loose the warnings about missing enum constants
though, so we must turn on -Wswitch-enum. To turn that on though,
we need to fix up various switch() statements that missed enum
values but had a default. After going to all that trouble it then
adds the default: to all remaining switches.
In doing this I found a reasonable number of bugs, where we would
call virXXXXXToString() methods with a _LAST constant - this is
not right as the _LAST constant can't be converted to a string as
it is a sentinal value only. So these were all fixed along the
way. At the same time various switches were improved such that
the value being switched on was cast to an enum type, to let the
compiler report missing enum cases.
A big cleanup but the code should be more robust against future
mistakes like the one fixed in patch 01.
There's a lot of patches here, but they're mostly independant of
each other so we can push them incrementally as they're reviewed,
so don't feel a need to review everything in one go !
Daniel P. Berrangé (42):
conf: add enum constants for default controller models
util: handle missing switch enum cases
conf: handle missing switch enum cases
esx: handle missing switch enum cases
hyperv: handle missing switch enum cases
libxl: handle missing switch enum cases
lxc: handle missing switch enum cases
nwfilter: handle missing switch enum cases
qemu: handle missing switch enum cases
rpc: handle missing switch enum cases
security: handle missing switch enum cases
xen: handle missing switch enum cases
tools: handle missing switch enum cases
m4: enforce that all enum cases are listed in switch statements
m4: disable gcc8 -Wcast-function-type warnings from -Wextra
util: add default: case to all switch statements
conf: add default: case to all switch statements
cpu: add default: case to all switch statements
secret: add default: case to all switch statements
xen: add default: case to all switch statements
locking: add default: case to all switch statements
test: add default: case to all switch statements
remote: add default: case to all switch statements
openvz: add default: case to all switch statements
security: add default: case to all switch statements
rpc: add default: case to all switch statements
vbox: add default: case to all switch statements
libxl: add default: case to all switch statements
qemu: add default: case to all switch statements
lxc: add default: case to all switch statements
uml: add default: case to all switch statements
bhyve: add default: case to all switch statements
network: add default: case to all switch statements
interface: add default: case to all switch statements
storage: add default: case to all switch statements
nodedev: add default: case to all switch statements
nwfilter: add default: case to all switch statements
daemon: add default: case to all switch statements
tests: add default: case to all switch statements
tools: add default: case to all switch statements
examples: add default: case to all switch statements
m4: enable the -Wswitch-default warning flag
daemon/libvirtd.c | 4 +-
daemon/remote.c | 4 +
examples/object-events/event-test.c | 24 ++
m4/virt-compile-warnings.m4 | 11 +-
po/POTFILES.in | 1 +
src/bhyve/bhyve_command.c | 12 +-
src/conf/device_conf.c | 4 +-
src/conf/domain_addr.c | 15 +-
src/conf/domain_audit.c | 5 +
src/conf/domain_conf.c | 514 ++++++++++++++++++++++++------
src/conf/domain_conf.h | 4 +
src/conf/domain_event.c | 1 +
src/conf/interface_conf.c | 21 +-
src/conf/netdev_bandwidth_conf.h | 4 +-
src/conf/network_conf.c | 8 +-
src/conf/network_event.c | 1 +
src/conf/node_device_conf.c | 27 +-
src/conf/node_device_event.c | 1 +
src/conf/nwfilter_conf.c | 33 +-
src/conf/nwfilter_params.c | 14 +
src/conf/secret_event.c | 1 +
src/conf/storage_event.c | 1 +
src/conf/virnodedeviceobj.c | 1 +
src/conf/virstorageobj.c | 1 +
src/cpu/cpu.c | 6 +-
src/cpu/cpu_ppc64.c | 16 +-
src/cpu/cpu_x86.c | 13 +-
src/esx/esx_driver.c | 1 +
src/esx/esx_vi.c | 11 +-
src/esx/esx_vi_types.c | 9 +-
src/hyperv/hyperv_driver.c | 18 +-
src/interface/interface_backend_udev.c | 12 +-
src/libvirt.c | 3 +
src/libvirt_private.syms | 6 +
src/libxl/libxl_conf.c | 57 +++-
src/libxl/libxl_domain.c | 23 +-
src/libxl/libxl_driver.c | 16 +-
src/libxl/libxl_logger.c | 2 +
src/locking/lock_driver_sanlock.c | 6 +-
src/locking/lock_manager.c | 2 +
src/locking/sanlock_helper.c | 5 +-
src/lxc/lxc_container.c | 7 +-
src/lxc/lxc_controller.c | 11 +-
src/lxc/lxc_driver.c | 42 ++-
src/lxc/lxc_process.c | 10 +-
src/network/bridge_driver.c | 46 ++-
src/network/leaseshelper.c | 11 +-
src/node_device/node_device_udev.c | 7 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 18 +-
src/nwfilter/nwfilter_gentech_driver.c | 23 +-
src/nwfilter/nwfilter_learnipaddr.c | 19 +-
src/openvz/openvz_driver.c | 3 +
src/qemu/qemu_alias.c | 3 +
src/qemu/qemu_block.c | 22 +-
src/qemu/qemu_blockjob.c | 1 +
src/qemu/qemu_capabilities.c | 23 +-
src/qemu/qemu_cgroup.c | 9 +-
src/qemu/qemu_command.c | 440 ++++++++++++++++++++-----
src/qemu/qemu_domain.c | 228 ++++++++++---
src/qemu/qemu_domain_address.c | 68 +++-
src/qemu/qemu_driver.c | 136 ++++++--
src/qemu/qemu_hostdev.c | 5 +-
src/qemu/qemu_hotplug.c | 94 +++++-
src/qemu/qemu_interface.c | 12 +-
src/qemu/qemu_migration.c | 35 +-
src/qemu/qemu_migration_cookie.c | 6 +-
src/qemu/qemu_monitor.c | 13 +-
src/qemu/qemu_monitor_json.c | 67 +++-
src/qemu/qemu_monitor_text.c | 3 +
src/qemu/qemu_parse_command.c | 12 +-
src/qemu/qemu_process.c | 110 ++++++-
src/remote/remote_driver.c | 19 +-
src/rpc/virnetclient.c | 2 +
src/rpc/virnetclientprogram.c | 1 +
src/rpc/virnetlibsshsession.c | 4 +
src/rpc/virnetservermdns.c | 5 +-
src/rpc/virnetserverprogram.c | 4 +
src/rpc/virnetsshsession.c | 8 +
src/secret/secret_util.c | 11 +-
src/security/security_apparmor.c | 12 +-
src/security/security_dac.c | 59 +++-
src/security/security_driver.c | 1 +
src/security/security_selinux.c | 69 +++-
src/storage/storage_backend_gluster.c | 12 +-
src/storage/storage_backend_rbd.c | 6 +-
src/storage/storage_driver.c | 1 +
src/storage/storage_util.c | 18 +-
src/test/test_driver.c | 2 +
src/uml/uml_conf.c | 5 +-
src/util/vircgroup.c | 1 +
src/util/virconf.c | 13 +-
src/util/vircrypto.c | 2 +
src/util/virerror.c | 6 +-
src/util/virfdstream.c | 4 +
src/util/virfirewall.c | 8 +-
src/util/virhook.c | 12 +-
src/util/virhostdev.c | 8 +-
src/util/virhostmem.c | 5 +
src/util/virjson.c | 5 +
src/util/virlog.c | 17 +-
src/util/virnetdev.c | 1 +
src/util/virnetdevmacvlan.c | 3 +
src/util/virnetdevvportprofile.c | 54 +++-
src/util/virnuma.c | 5 +-
src/util/virprocess.c | 1 +
src/util/virqemu.c | 5 +
src/util/virsexpr.c | 2 +
src/util/virsocketaddr.c | 13 +-
src/util/virstoragefile.c | 15 +-
src/vbox/vbox_common.c | 42 ++-
src/vmx/vmx.c | 27 +-
src/xen/xen_driver.c | 17 +-
src/xenconfig/xen_common.c | 23 +-
src/xenconfig/xen_sxpr.c | 47 ++-
src/xenconfig/xen_xl.c | 28 +-
tests/cputest.c | 31 +-
tests/domaincapstest.c | 1 +
tests/qemuhotplugtest.c | 4 +
tests/storagevolxml2argvtest.c | 2 +
tests/virusbtest.c | 6 +
tools/virsh-domain-monitor.c | 4 +
tools/virsh-domain.c | 14 +-
tools/virsh-nodedev.c | 1 +
tools/virsh-pool.c | 1 +
tools/virsh.c | 1 +
tools/virt-admin.c | 1 +
tools/virt-host-validate-qemu.c | 3 +-
tools/vsh.c | 5 +
128 files changed, 2567 insertions(+), 512 deletions(-)
--
2.14.3
6 years, 10 months
[libvirt] [PATCH] Fix build with GCC 8 new switch fallthrough warnings
by Daniel P. Berrangé
GCC 8 became more fussy about detecting switch
fallthroughs. First it doesn't like it if you have
a fallthrough attribute that is not before a case
statement. e.g.
FOO:
BAR:
WIZZ:
ATTRIBUTE_FALLTHROUGH;
Is unacceptable as there's no final case statement,
so while FOO & BAR are falling through, WIZZ is
not falling through. IOW, GCC wants us to write
FOO:
BAR:
ATTRIBUTE_FALLTHROUGH;
WIZZ:
Second, it will report risk of fallthrough even if you
have a case statement for every single enum value, but
only if the switch is nested inside another switch and
the outer case statement has no final break. This is
is arguably valid because despite the fact that we have
cast from "int" to the enum typedef, nothing guarantees
that the variable we're switching on only contains values
that have corresponding switch labels. e.g.
int domstate = 87539319;
switch ((virDomainState)domstate) {
...
}
will not match enum value, but also not raise any kind
of compiler warning. So it is right to complain about
risk of fallthrough if no default: is present.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed as a minimal build-fix for Fedora rawhide, since the bigger
switch cleanup series is taking a while to get ready for merge.
src/qemu/qemu_domain.c | 6 ++++--
src/qemu/qemu_domain_address.c | 10 ++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 593b9d0fb5..b1308e5a49 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -173,8 +173,9 @@ qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_SNAPSHOT:
case QEMU_ASYNC_JOB_START:
case QEMU_ASYNC_JOB_NONE:
- case QEMU_ASYNC_JOB_LAST:
ATTRIBUTE_FALLTHROUGH;
+ case QEMU_ASYNC_JOB_LAST:
+ break;
}
return "none";
@@ -197,8 +198,9 @@ qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_SNAPSHOT:
case QEMU_ASYNC_JOB_START:
case QEMU_ASYNC_JOB_NONE:
- case QEMU_ASYNC_JOB_LAST:
ATTRIBUTE_FALLTHROUGH;
+ case QEMU_ASYNC_JOB_LAST:
+ break;
}
if (STREQ(phase, "none"))
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index dd3e703ca5..001c84a906 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -543,6 +543,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
return pciFlags;
@@ -567,6 +568,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
return virtioFlags;
@@ -619,6 +621,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_SOUND_MODEL_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_DISK:
switch ((virDomainDiskBus) dev->data.disk->bus) {
@@ -636,6 +639,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DISK_BUS_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_HOSTDEV: {
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
@@ -748,6 +752,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_MEMBALLOON_MODEL_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_RNG:
switch ((virDomainRNGModel) dev->data.rng->model) {
@@ -757,6 +762,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_RNG_MODEL_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_WATCHDOG:
/* only one model connects using PCI */
@@ -769,6 +775,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_WATCHDOG_MODEL_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_VIDEO:
switch ((virDomainVideoType) dev->data.video->type) {
@@ -789,6 +796,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_VIDEO_TYPE_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_SHMEM:
return pciFlags;
@@ -805,6 +813,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_INPUT_BUS_LAST:
return 0;
}
+ break;
case VIR_DOMAIN_DEVICE_CHR:
switch ((virDomainChrSerialTargetType) dev->data.chr->targetType) {
@@ -820,6 +829,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
return 0;
}
+ break;
/* These devices don't ever connect with PCI */
case VIR_DOMAIN_DEVICE_NVRAM:
--
2.14.3
6 years, 10 months
[libvirt] [PATCH v2] conf: add enum constants for default controller models
by Daniel P. Berrangé
The controller model is slightly unusual in that the default value is
-1, not 0. As a result the default value is not covered by any of the
existing enum cases. This in turn means that any switch() statements
that think they have covered all cases, will in fact not match the
default value at all. In the qemuDomainDeviceCalculatePCIConnectFlags()
method this has caused a serious mistake where we fallthrough from the
SCSI controller case, to the VirtioSerial controller case, and from
the USB controller case to the IDE controller case.
By adding explicit enum constant starting at -1, we can ensure switches
remember to handle the default case.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/conf/domain_addr.c | 6 +++---
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 4 ++++
src/libxl/libxl_conf.c | 2 +-
src/qemu/qemu_command.c | 21 ++++++++++++++++-----
src/qemu/qemu_domain.c | 14 +++++++++++---
src/qemu/qemu_domain_address.c | 19 +++++++++++++++++--
src/qemu/qemu_hotplug.c | 2 +-
src/vbox/vbox_common.c | 13 +++++++++----
src/vmx/vmx.c | 2 +-
10 files changed, 65 insertions(+), 21 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 6422682391..4f969adc00 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -39,6 +39,7 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
* the equivalent VIR_PCI_CONNECT_TYPE_*.
*/
switch (model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
@@ -344,6 +345,7 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("PCI controller model was not set correctly"));
@@ -1710,10 +1712,8 @@ virDomainUSBAddressControllerModelToPorts(virDomainControllerDefPtr cont)
{
int model = cont->model;
- if (model == -1)
- model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
-
switch ((virDomainControllerModelUSB) model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI:
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 970efbb13c..28e4f6f681 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4999,7 +4999,7 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
* been added in AddImplicitDevices, after we've done the per-device
* post-parse. */
for (i = 0; i < def->ncontrollers; i++) {
- if (def->controllers[i]->model == -1 &&
+ if (def->controllers[i]->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT &&
def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
virDomainDeviceDef device = {
.type = VIR_DOMAIN_DEVICE_CONTROLLER,
@@ -10197,6 +10197,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
/* Other controller models don't require extra checks */
break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 117efb1d1d..2350926e5b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -685,6 +685,7 @@ typedef enum {
typedef enum {
+ VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT = -1,
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
@@ -714,6 +715,7 @@ typedef enum {
} virDomainControllerPCIModelName;
typedef enum {
+ VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT = -1,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC,
@@ -727,6 +729,7 @@ typedef enum {
} virDomainControllerModelSCSI;
typedef enum {
+ VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT = -1,
VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI,
VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI,
VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI,
@@ -746,6 +749,7 @@ typedef enum {
} virDomainControllerModelUSB;
typedef enum {
+ VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT = -1,
VIR_DOMAIN_CONTROLLER_MODEL_IDE_PIIX3,
VIR_DOMAIN_CONTROLLER_MODEL_IDE_PIIX4,
VIR_DOMAIN_CONTROLLER_MODEL_IDE_ICH6,
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 970cff205b..0c5de344de 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1894,7 +1894,7 @@ libxlMakeUSBController(virDomainControllerDefPtr controller,
if (controller->type != VIR_DOMAIN_CONTROLLER_TYPE_USB)
return -1;
- if (controller->model == -1) {
+ if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) {
usbctrl->version = 2;
usbctrl->type = LIBXL_USBCTRL_TYPE_QUSB;
} else {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0c6a6cbd15..f8526a6454 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2555,7 +2555,7 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def,
model = def->model;
- if (model == -1) {
+ if (model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("no model provided for USB controller"));
return -1;
@@ -2671,10 +2671,16 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI:
- case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller model: %s"),
virDomainControllerModelSCSITypeToString(def->model));
+ goto error;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected SCSI controller model %d"),
+ def->model);
+ goto error;
}
virBufferAsprintf(&buf, ",id=%s", def->info.alias);
break;
@@ -2771,9 +2777,14 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
virBufferAsprintf(&buf, ",numa_node=%d", pciopts->numaNode);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Unsupported PCI Express root controller"));
+ goto error;
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("wrong function called"));
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected PCI controller model %d"),
+ def->model);
goto error;
}
break;
@@ -2905,7 +2916,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
}
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
- cont->model == -1 &&
+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT &&
!qemuDomainIsQ35(def) &&
!qemuDomainIsVirt(def)) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5d0a18343e..593b9d0fb5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4139,11 +4139,16 @@ qemuDomainCheckSCSIControllerModel(virQEMUCapsPtr qemuCaps,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI:
- case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller model: %s"),
virDomainControllerModelSCSITypeToString(model));
return false;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected SCSI controller model %d"),
+ model);
+ return false;
}
return true;
@@ -4230,6 +4235,7 @@ qemuDomainDeviceDefValidateControllerSCSI(const virDomainControllerDef *controll
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078:
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
break;
}
@@ -4277,6 +4283,7 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *controlle
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
break;
}
@@ -4509,6 +4516,7 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *controlle
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
break;
}
@@ -4861,7 +4869,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
break;
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
- if (cont->model == -1 && qemuCaps) {
+ if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT && qemuCaps) {
/* Pick a suitable default model for the USB controller if none
* has been selected by the user and we have the qemuCaps for
* figuring out which contollers are supported.
@@ -5879,7 +5887,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
*/
if (ARCH_IS_X86(def->os.arch) && qemuDomainIsI440FX(def) &&
usb && usb->idx == 0 &&
- (usb->model == -1 ||
+ (usb->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT ||
usb->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI)) {
VIR_DEBUG("Removing default USB controller from domain '%s'"
" for migration compatibility", def->name);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index e28119e4b1..dd3e703ca5 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -513,6 +513,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
switch ((virDomainControllerModelUSB) cont->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT:
+ /* qemuDomainControllerDefPostParse should have
+ * changed 'model' to an explicit USB model in
+ * most cases. Since we're still on the default
+ * though, we must be going to use "-usb", which
+ * is assumed to be a PCI default
+ */
+ return pciFlags;
+
case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI:
return pcieFlags;
@@ -540,6 +549,9 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
switch ((virDomainControllerModelSCSI) cont->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
+ return 0;
+
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
return virtioFlags;
@@ -1275,7 +1287,8 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
addr->function == 1) ||
(cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && cont->idx == 0 &&
(cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI ||
- cont->model == -1) && addr->function == 2)) {
+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) &&
+ addr->function == 2)) {
/* Note the check for nbuses > 0 - if there are no PCI
* buses, we skip this check. This is a quirk required for
* some machinetypes such as s390, which pretend to have a
@@ -1435,7 +1448,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
} else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
cont->idx == 0 &&
(cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI ||
- cont->model == -1)) {
+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT)) {
if (virDeviceInfoPCIAddressPresent(&cont->info)) {
if (cont->info.addr.pci.domain != 0 ||
cont->info.addr.pci.bus != 0 ||
@@ -2165,6 +2178,7 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont,
*modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
break;
}
@@ -2552,6 +2566,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
break;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3c87d73745..04f4f689a9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -612,7 +612,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver,
return NULL;
cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
cont->idx = controller;
- if (model == -1)
+ if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT)
cont->model = qemuDomainGetSCSIControllerModel(vm->def, cont, priv->qemuCaps);
else
cont->model = model;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index aed14f02d7..07f4308784 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -410,12 +410,17 @@ vboxSetStorageController(virDomainControllerDefPtr controller,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078:
- case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("The vbox driver does not support %s SCSI "
"controller model"),
virDomainControllerModelSCSITypeToString(controller->model));
goto cleanup;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unexpected SCSI controller model %d"),
+ controller->model);
+ goto cleanup;
}
/* libvirt ide model => vbox ide model */
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
@@ -433,10 +438,10 @@ vboxSetStorageController(virDomainControllerDefPtr controller,
break;
case VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST:
+ case VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("The vbox driver does not support %s IDE "
- "controller model"),
- virDomainControllerModelIDETypeToString(controller->model));
+ _("Unexpected IDE controller model %d"),
+ controller->model);
goto cleanup;
}
}
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 7a749f93ab..1d13ab03db 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1169,7 +1169,7 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def,
return -1;
}
- if (controller->model == -1) {
+ if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT) {
controller->model = model;
} else if (controller->model != model) {
virReportError(VIR_ERR_INTERNAL_ERROR,
--
2.14.3
6 years, 10 months