[libvirt] [PATCHv2 0/1] Function declarations match definitions
by Chris Venteicher
Interested in fixing mismatches between function parameter names in declarations
(header files) and definitions (.c files)?
This is a cosmetic / redability fix and does not change functionality.
This is patch 1 of larger set of 22 patches that fix parameter names across the
libvirt source code. If there is interest I can send the entire patch set.
These are cosmetic redability fixes automatically generated by clang-tidy.
make check and make syntax-check pass successfully after the 22 patches are
applied.
This is my first submission so please point out any issues and I will be glad to
fix.
Chris Venteicher (1):
include: function parameter names same in declaration
include/libvirt/libvirt-domain.h | 18 +++++++-------
include/libvirt/libvirt-event.h | 4 ++--
include/libvirt/libvirt-host.h | 4 ++--
include/libvirt/libvirt-network.h | 4 ++--
include/libvirt/libvirt-nwfilter.h | 2 +-
include/libvirt/libvirt-qemu.h | 2 +-
include/libvirt/libvirt-secret.h | 4 ++--
include/libvirt/libvirt-storage.h | 12 +++++-----
include/libvirt/libvirt-stream.h | 22 ++++++++---------
src/libvirt-domain.c | 48 +++++++++++++++++++-------------------
src/libvirt-network.c | 10 ++++----
11 files changed, 65 insertions(+), 65 deletions(-)
--
2.14.1
6 years, 9 months
[libvirt] Default USB controller model vs PCI address assignment
by Daniel P. Berrangé
GCC8 identified a critical flaw in the QEMU post-parse callback
They switch() based on the virDomainControllDef 'model', carefully
listing every single enum case..... but no default statement.
Unfortunately it is valid for "model" to have the valid "-1"
which does not map to any enum constant. So the lack of any
"default" statement, means when dealing with the USB controller
we mistakenly fall through to the IDE controller code.
The SCSI controller simililarly falls through to the virtio
serial controller case.
I tried just adding the obvious default case:
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index e28119e4b..3eaa22e39 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -532,6 +532,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2: /* xen only */
case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
+ default:
return 0;
}
@@ -553,6 +554,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return pciFlags;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ default:
return 0;
}
This causes many of the QEMU test cases to fail now with a message
"internal error: Cannot automatically add a new PCI bus for a device
with connect flags 00"
I could theoretically make the "default:" case return "pciFlags" when
model == -1, but this seems dubious because it feels like it is blindly
assuming that any unknown controller model is PCI based, but it would
be functionally equivalent to the current behaviour where USB accidentally
falls through to the IDE code.
Thoughts ?
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
6 years, 9 months
[libvirt] [PATCH v2 0/3] Fix compat with GCC8
by Daniel P. Berrangé
In this second version I enable -Wswitch-enum to strongly validate
all switches cover all enum cases.
Daniel P. Berrangé (3):
Turn on -Wswitch-enum and fix all problems it identifies
Fix more switch fallthrough identified by gcc8
Disable gcc8 -Wcast-function-type warnings from -Wextra
m4/virt-compile-warnings.m4 | 9 ++++--
src/conf/domain_audit.c | 1 +
src/conf/domain_conf.c | 47 +++++++++++++++++++++++++++----
src/conf/nwfilter_conf.c | 32 ++++++++++++++++++++-
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 | 7 +++--
src/lxc/lxc_controller.c | 10 ++++++-
src/lxc/lxc_driver.c | 40 +++++++++++++++++++++++---
src/nwfilter/nwfilter_ebiptables_driver.c | 16 +++++++----
src/nwfilter/nwfilter_learnipaddr.c | 6 +++-
src/qemu/qemu_command.c | 28 ++++++++++++------
src/qemu/qemu_domain.c | 35 ++++++++++++++++++-----
src/qemu/qemu_domain_address.c | 11 ++++++++
src/qemu/qemu_driver.c | 27 ++++++++++++------
src/qemu/qemu_hotplug.c | 36 +++++++++++++++++++----
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 | 13 ++++++++-
src/util/virfirewall.c | 7 +++--
src/util/virlog.c | 10 ++++++-
src/util/virnetdevvportprofile.c | 11 +++++++-
src/vmx/vmx.c | 27 ++++++++++++++++--
src/xenconfig/xen_common.c | 17 +++++++++--
src/xenconfig/xen_xl.c | 8 +++++-
tools/virt-host-validate-qemu.c | 3 +-
33 files changed, 389 insertions(+), 74 deletions(-)
--
2.16.1
6 years, 9 months
[libvirt] [PATCH 0/6] Cleanups in QEMU driver wrt virConnectPtr
by Daniel P. Berrangé
There are many places we can stop passing around virConnectPtr now
and directly open secondary drivers where required instead.
Daniel P. Berrangé (6):
conf: reimplement virDomainNetResolveActualType in terms of public API
qemu: stop passing virConnectPtr into qemuMonitorStartCPUs
conf: stop passing virConnectPtr into virDomainDiskTranslateSourcePool
qemu: don't pass virConnectPtr around for secrets
qemu: stop passing in virConnectPtr for looking up networks
qemu: remove virConnectPtr from some more startup code paths
src/conf/domain_conf.c | 90 +++++++++++++++++++++++++----
src/conf/domain_conf.h | 14 +----
src/network/bridge_driver.c | 76 +-----------------------
src/qemu/qemu_conf.c | 3 +-
src/qemu/qemu_conf.h | 3 +-
src/qemu/qemu_domain.c | 111 +++++++++++++++++------------------
src/qemu/qemu_domain.h | 15 ++---
src/qemu/qemu_driver.c | 126 +++++++++++++++-------------------------
src/qemu/qemu_hotplug.c | 66 +++++++++------------
src/qemu/qemu_hotplug.h | 15 ++---
src/qemu/qemu_migration.c | 18 +++---
src/qemu/qemu_monitor.c | 10 ++--
src/qemu/qemu_monitor.h | 11 +---
src/qemu/qemu_monitor_json.c | 3 +-
src/qemu/qemu_monitor_json.h | 3 +-
src/qemu/qemu_monitor_text.c | 9 +--
src/qemu/qemu_monitor_text.h | 3 +-
src/qemu/qemu_process.c | 134 +++++++++++++++++--------------------------
src/qemu/qemu_process.h | 12 ++--
tests/qemuhotplugtest.c | 4 +-
tests/qemumonitorjsontest.c | 2 +-
21 files changed, 298 insertions(+), 430 deletions(-)
--
2.14.3
6 years, 9 months
[libvirt] Developing libvirt for virtual devices like virtual printers
by Deepti S
Hi,
I have a couple of questions.
- I am a new libvirt code developer. I have just cloned the repo and I am
looking for a suitable debugger/IDE which will help me debug the code.
- I work in developing and creating virtual printers with display, with
QEMU as the hypervisor (no KVM-only Qemu).
Currently we have our own application to manage the virtual printers.
Our plan is to migrate to libvirt, and enable our application to use the
libvirt APIs.
libvirt code currently looks to be specialized in pure OS-specific
guests (like PCs), and I hit snags where there are manadatory devices added
which a virtual printer does not need.
Are there any developers who are looking into customized virtual
devices? I would like to knowledge share with them.
The intention is to provide new libvirt APIs whenever there is such a
snag and thus enable libvirt to be used for managing virtual printers.
- One issue that we are seeing is with regard to USB Host Controller:
We have a customized model of ehci USB Host Controller (named
nr52_ehci_usb) in qemu (locally built).
When I add the custom value (n552_ehci_usb) of the host controller as
the "model" type in my dom xml, virsh define <xml> fails with invalid model
type error.
I remove the usb controller entry from the xml, and add "-usb" as a
"qemucommandline" parameter, but then libvirt adds the device lsi (-device
lsi,id=scsi0 -usb), and the virsh create command fails with:
"-device lsi,id=scsi0 No PCI bus found for lsi53c895a".
The board we have created in QEMU does not have PCI bus implemented.
I am interested in the code related to host controllers.
Is there any way I can get my usb host controller to be recognized by
libvirt?
Is there a way I can prevent lsi device from getting added when I make
-usb a qemu command line parameter?
Regards,
Deepti
6 years, 9 months
[libvirt] [PATCH libvirt] tests: run virshtest independent of current pwd
by Bjoern Walk
virshtest execves the virsh binary. Make sure that it finds the binary's
location independent of the current working directory by specifying the
absolute path as determined by the build environment.
Reviewed-by: Marc Hartmayer <mhartmay(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
---
tests/virshtest.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 67453bd9..94548a82 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -84,13 +84,13 @@ testCompareOutputLit(const char *expectData,
return result;
}
-# define VIRSH_DEFAULT "../tools/virsh", \
+# define VIRSH_DEFAULT abs_topbuilddir "/tools/virsh", \
"--connect", \
"test:///default"
static char *custom_uri;
-# define VIRSH_CUSTOM "../tools/virsh", \
+# define VIRSH_CUSTOM abs_topbuilddir "/tools/virsh", \
"--connect", \
custom_uri
--
2.13.4
6 years, 9 months
[libvirt] [RFC] virSysinfo: Introduce SMBIOS type 3 support
by Zhuangyanying
From: Zhuang Yanying <ann.zhuangyanying(a)huawei.com>
Some applications inside VM need to access SMBIOS Chassis Asset Tag,
which should be emulated. It has already been realized in qemu,
SMBIOS: Build aggregate smbios tables and entry point
https://git.qemu.org/?p=qemu.git;a=commit;h=c97294ec1b9e36887e119589d4565...
but not in libvirt. we realize it here.
As an example, you could use something like
<chassis>
<entry name='manufacturer'>LENOVO</entry>
<entry name='version'>0B98401 Pro</entry>
<entry name='serial'>W1KS427111E</entry>
<entry name='asset'>344dfTYH#</entry>
</chassis>
---
src/conf/domain_conf.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_command.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/virsysinfo.c | 37 +++++++++++++++++++++++++++++++++++
src/util/virsysinfo.h | 13 +++++++++++++
4 files changed, 151 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 34aae82..b0d5d68 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14506,6 +14506,47 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt,
return ret;
}
+static int
+virSysinfoChassisParseXML(xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ virSysinfoChassisDefPtr *chassisdef)
+{
+ int ret = -1;
+ virSysinfoChassisDefPtr def;
+
+ if (!xmlStrEqual(node->name, BAD_CAST "chassis")) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("XML does not contain expected 'chassis' element"));
+ return ret;
+ }
+
+ if (VIR_ALLOC(def) < 0)
+ goto cleanup;
+
+ def->manufacturer =
+ virXPathString("string(entry[@name='manufacturer'])", ctxt);
+ def->version =
+ virXPathString("string(entry[@name='version'])", ctxt);
+ def->serial =
+ virXPathString("string(entry[@name='serial'])", ctxt);
+ def->asset =
+ virXPathString("string(entry[@name='asset'])", ctxt);
+ def->sku =
+ virXPathString("string(entry[@name='sku'])", ctxt);
+
+ if (!def->manufacturer && !def->version &&
+ !def->serial && !def->asset && !def->sku) {
+ virSysinfoChassisDefFree(def);
+ def = NULL;
+ }
+
+ *chassisdef = def;
+ def = NULL;
+ ret = 0;
+ cleanup:
+ virSysinfoChassisDefFree(def);
+ return ret;
+}
static int
virSysinfoOEMStringsParseXML(xmlXPathContextPtr ctxt,
@@ -14600,6 +14641,17 @@ virSysinfoParseXML(xmlNodePtr node,
if (virSysinfoBaseBoardParseXML(ctxt, &def->baseBoard, &def->nbaseBoard) < 0)
goto error;
+ /* Extract chassis metadata */
+ if ((tmpnode = virXPathNode("./chassis[1]", ctxt)) != NULL) {
+ oldnode = ctxt->node;
+ ctxt->node = tmpnode;
+ if (virSysinfoChassisParseXML(tmpnode, ctxt, &def->chassis) < 0) {
+ ctxt->node = oldnode;
+ goto error;
+ }
+ ctxt->node = oldnode;
+ }
+
/* Extract system related metadata */
if ((tmpnode = virXPathNode("./oemStrings[1]", ctxt)) != NULL) {
oldnode = ctxt->node;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 24b434a..cf88e75 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5813,6 +5813,49 @@ qemuBuildSmbiosBaseBoardStr(virSysinfoBaseBoardDefPtr def)
return NULL;
}
+static char *
+qemuBuildSmbiosChassisStr(virSysinfoChassisDefPtr def)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (!def)
+ return NULL;
+
+ virBufferAddLit(&buf, "type=3");
+
+ /* 2:Manufacturer */
+ virBufferAddLit(&buf, ",manufacturer=");
+ virQEMUBuildBufferEscapeComma(&buf, def->manufacturer);
+ /* 2:Version */
+ if (def->version) {
+ virBufferAddLit(&buf, ",version=");
+ virQEMUBuildBufferEscapeComma(&buf, def->version);
+ }
+ /* 2:Serial Number */
+ if (def->serial) {
+ virBufferAddLit(&buf, ",serial=");
+ virQEMUBuildBufferEscapeComma(&buf, def->serial);
+ }
+ /* 2:Asset Tag */
+ if (def->asset) {
+ virBufferAddLit(&buf, ",asset=");
+ virQEMUBuildBufferEscapeComma(&buf, def->asset);
+ }
+ /* 2:Sku */
+ if (def->sku) {
+ virBufferAddLit(&buf, ",sku=");
+ virQEMUBuildBufferEscapeComma(&buf, def->sku);
+ }
+
+ if (virBufferCheckError(&buf) < 0)
+ goto error;
+
+ return virBufferContentAndReset(&buf);
+
+ error:
+ virBufferFreeAndReset(&buf);
+ return NULL;
+}
static char *
qemuBuildSmbiosOEMStringsStr(virSysinfoOEMStringsDefPtr def)
@@ -5905,6 +5948,12 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd,
VIR_FREE(smbioscmd);
}
+ smbioscmd = qemuBuildSmbiosChassisStr(source->chassis);
+ if (smbioscmd != NULL) {
+ virCommandAddArgList(cmd, "-smbios", smbioscmd, NULL);
+ VIR_FREE(smbioscmd);
+ }
+
if (source->oemStrings) {
if (!(smbioscmd = qemuBuildSmbiosOEMStringsStr(source->oemStrings)))
return -1;
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index e8d3371..af434e0 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -108,6 +108,18 @@ void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDefPtr def)
VIR_FREE(def->location);
}
+void virSysinfoChassisDefFree(virSysinfoChassisDefPtr def)
+{
+ if (def == NULL)
+ return;
+
+ VIR_FREE(def->manufacturer);
+ VIR_FREE(def->version);
+ VIR_FREE(def->serial);
+ VIR_FREE(def->asset);
+ VIR_FREE(def->sku);
+}
+
void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def)
{
size_t i;
@@ -143,6 +155,8 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
virSysinfoBaseBoardDefClear(def->baseBoard + i);
VIR_FREE(def->baseBoard);
+ virSysinfoChassisDefFree(def->chassis);
+
for (i = 0; i < def->nprocessor; i++) {
VIR_FREE(def->processor[i].processor_socket_destination);
VIR_FREE(def->processor[i].processor_type);
@@ -1203,6 +1217,28 @@ virSysinfoBaseBoardFormat(virBufferPtr buf,
}
static void
+virSysinfoChassisFormat(virBufferPtr buf, virSysinfoChassisDefPtr def)
+{
+ if (!def)
+ return;
+
+ virBufferAddLit(buf, "<chassis>\n");
+ virBufferAdjustIndent(buf, 2);
+ virBufferEscapeString(buf, "<entry name='manufacturer'>%s</entry>\n",
+ def->manufacturer);
+ virBufferEscapeString(buf, "<entry name='version'>%s</entry>\n",
+ def->version);
+ virBufferEscapeString(buf, "<entry name='serial'>%s</entry>\n",
+ def->serial);
+ virBufferEscapeString(buf, "<entry name='asset'>%s</entry>\n",
+ def->asset);
+ virBufferEscapeString(buf, "<entry name='sku'>%s</entry>\n",
+ def->sku);
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</chassis>\n");
+}
+
+static void
virSysinfoProcessorFormat(virBufferPtr buf, virSysinfoDefPtr def)
{
size_t i;
@@ -1354,6 +1390,7 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)
virSysinfoBIOSFormat(&childrenBuf, def->bios);
virSysinfoSystemFormat(&childrenBuf, def->system);
virSysinfoBaseBoardFormat(&childrenBuf, def->baseBoard, def->nbaseBoard);
+ virSysinfoChassisFormat(&childrenBuf, def->chassis);
virSysinfoProcessorFormat(&childrenBuf, def);
virSysinfoMemoryFormat(&childrenBuf, def);
virSysinfoOEMStringsFormat(&childrenBuf, def->oemStrings);
diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h
index ecb3a36..00a15db 100644
--- a/src/util/virsysinfo.h
+++ b/src/util/virsysinfo.h
@@ -98,6 +98,16 @@ struct _virSysinfoBaseBoardDef {
/* XXX board type */
};
+typedef struct _virSysinfoChassisDef virSysinfoChassisDef;
+typedef virSysinfoChassisDef *virSysinfoChassisDefPtr;
+struct _virSysinfoChassisDef {
+ char *manufacturer;
+ char *version;
+ char *serial;
+ char *asset;
+ char *sku;
+};
+
typedef struct _virSysinfoOEMStringsDef virSysinfoOEMStringsDef;
typedef virSysinfoOEMStringsDef *virSysinfoOEMStringsDefPtr;
struct _virSysinfoOEMStringsDef {
@@ -116,6 +126,8 @@ struct _virSysinfoDef {
size_t nbaseBoard;
virSysinfoBaseBoardDefPtr baseBoard;
+ virSysinfoChassisDefPtr chassis;
+
size_t nprocessor;
virSysinfoProcessorDefPtr processor;
@@ -130,6 +142,7 @@ virSysinfoDefPtr virSysinfoRead(void);
void virSysinfoBIOSDefFree(virSysinfoBIOSDefPtr def);
void virSysinfoSystemDefFree(virSysinfoSystemDefPtr def);
void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDefPtr def);
+void virSysinfoChassisDefFree(virSysinfoChassisDefPtr def);
void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def);
void virSysinfoDefFree(virSysinfoDefPtr def);
--
1.8.3.1
6 years, 9 months
[libvirt] [PATCH 00/11] Fixes and improvements to feature handling
by Andrea Bolognani
This series is the result of shaving many a yak while implementing
support for pSeries optional features (first attempt at [1], respin
coming right after I send this).
Quick summary of the changes:
* handle more sanely cases where the GIC capability has been
enabled but no GIC version has been provided;
* use the switch construct more, so that the compiler can warn us
when we forget to handle some feature;
* where possible (eg. the value is mandatory and there is only a
limited number of options to choose from) avoid storing whether
a feature is enabled and its actual value separately.
Save for the first one, none of the changes should be visible to
the user, but they will hopefully improve things for developers.
[1] https://www.redhat.com/archives/libvir-list/2018-January/msg00779.html
Andrea Bolognani (11):
qemu: Move feature verification from PostParse() to Validate()
qemu: Use switch in qemuDomainDefValidateFeatures()
qemu: Move GIC checks to qemuDomainDefValidateFeatures()
conf: Use switch in virDomainDefFeaturesCheckABIStability()
conf: Validate VIR_DOMAIN_FEATURE_CAPABILITIES properly
conf: Integrate all features ABI checks in the switch
tests: Improve GIC tests
qemu: Fix GIC behavior for the default case
conf: Improve IOAPIC feature handling
conf: Improve HPT feature handling
tests: Clean up HPT tests
src/conf/domain_conf.c | 174 +++++++++++++--------
src/conf/domain_conf.h | 15 +-
src/libvirt_private.syms | 2 +
src/qemu/qemu_command.c | 16 +-
src/qemu/qemu_domain.c | 117 +++++++++-----
.../qemuxml2argvdata/aarch64-gic-default-both.args | 1 +
.../qemuxml2argvdata/aarch64-gic-default-both.xml | 1 +
tests/qemuxml2argvdata/aarch64-gic-default-v2.args | 1 +
tests/qemuxml2argvdata/aarch64-gic-default-v2.xml | 1 +
tests/qemuxml2argvdata/aarch64-gic-default-v3.args | 1 +
tests/qemuxml2argvdata/aarch64-gic-default-v3.xml | 1 +
...hpt-resizing.args => pseries-features-hpt.args} | 1 -
.../pseries-features-hpt.xml} | 0
...ne.xml => pseries-features-invalid-machine.xml} | 2 +-
tests/qemuxml2argvdata/pseries-hpt-resizing.xml | 19 ---
tests/qemuxml2argvtest.c | 29 ++--
.../aarch64-gic-default-both.xml | 1 +
.../qemuxml2xmloutdata/aarch64-gic-default-v2.xml | 1 +
.../qemuxml2xmloutdata/aarch64-gic-default-v3.xml | 1 +
tests/qemuxml2xmloutdata/pseries-features-hpt.xml | 1 +
tests/qemuxml2xmltest.c | 9 +-
21 files changed, 230 insertions(+), 164 deletions(-)
create mode 120000 tests/qemuxml2argvdata/aarch64-gic-default-both.args
create mode 120000 tests/qemuxml2argvdata/aarch64-gic-default-both.xml
create mode 120000 tests/qemuxml2argvdata/aarch64-gic-default-v2.args
create mode 120000 tests/qemuxml2argvdata/aarch64-gic-default-v2.xml
create mode 120000 tests/qemuxml2argvdata/aarch64-gic-default-v3.args
create mode 120000 tests/qemuxml2argvdata/aarch64-gic-default-v3.xml
rename tests/qemuxml2argvdata/{pseries-hpt-resizing.args => pseries-features-hpt.args} (96%)
rename tests/{qemuxml2xmloutdata/pseries-hpt-resizing.xml => qemuxml2argvdata/pseries-features-hpt.xml} (100%)
rename tests/qemuxml2argvdata/{pseries-hpt-resizing-invalid-machine.xml => pseries-features-invalid-machine.xml} (86%)
delete mode 100644 tests/qemuxml2argvdata/pseries-hpt-resizing.xml
create mode 120000 tests/qemuxml2xmloutdata/aarch64-gic-default-both.xml
create mode 120000 tests/qemuxml2xmloutdata/aarch64-gic-default-v2.xml
create mode 120000 tests/qemuxml2xmloutdata/aarch64-gic-default-v3.xml
create mode 120000 tests/qemuxml2xmloutdata/pseries-features-hpt.xml
--
2.14.3
6 years, 9 months
[libvirt] [PATCH] Fix build with GCC 8 new warnings
by Daniel P. Berrangé
GCC 8 added a -Wcast-function-type warning to -Wextra by
default. This complains if you try to explicitly cast
one function signature to another function signature
with incompatible args. This is something we do many
times in libvirt especially with event callbacks. The
hack to silence the warning requires casting via a
void(*)(void) signature before casting to the desired
type. This gross, so we just disable this new warning.
GCC 8 also 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>
---
m4/virt-compile-warnings.m4 | 2 ++
src/qemu/qemu_domain.c | 14 +++++++-------
src/qemu/qemu_domain_address.c | 11 +++++++++++
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index b9c974842..4b35a6f6b 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -177,6 +177,8 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
# with gl_MANYWARN_COMPLEMENT
# So we have -W enabled, and then have to explicitly turn off...
wantwarn="$wantwarn -Wno-sign-compare"
+ # We do "bad" function casts all the time for event callbacks
+ wantwarn="$wantwarn -Wno-cast-function-type"
# GNULIB expects this to be part of -Wc++-compat, but we turn
# that one off, so we need to manually enable this again
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 178ec24ae..560436f8e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -175,9 +175,9 @@ qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_LAST:
ATTRIBUTE_FALLTHROUGH;
+ default:
+ return "none";
}
-
- return "none";
}
int
@@ -199,12 +199,12 @@ qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
case QEMU_ASYNC_JOB_NONE:
case QEMU_ASYNC_JOB_LAST:
ATTRIBUTE_FALLTHROUGH;
+ default:
+ if (STREQ(phase, "none"))
+ return 0;
+ else
+ return -1;
}
-
- if (STREQ(phase, "none"))
- return 0;
- else
- return -1;
}
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index e28119e4b..42c7c0b12 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -532,6 +532,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2: /* xen only */
case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
+ default:
return 0;
}
@@ -553,6 +554,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return pciFlags;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
+ default:
return 0;
}
@@ -562,6 +564,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ default:
/* should be 0 */
return pciFlags;
}
@@ -605,6 +608,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_SOUND_MODEL_PCSPK:
case VIR_DOMAIN_SOUND_MODEL_USB:
case VIR_DOMAIN_SOUND_MODEL_LAST:
+ default:
return 0;
}
@@ -622,6 +626,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
+ default:
return 0;
}
@@ -734,6 +739,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_MEMBALLOON_MODEL_XEN:
case VIR_DOMAIN_MEMBALLOON_MODEL_NONE:
case VIR_DOMAIN_MEMBALLOON_MODEL_LAST:
+ default:
return 0;
}
@@ -743,6 +749,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return virtioFlags;
case VIR_DOMAIN_RNG_MODEL_LAST:
+ default:
return 0;
}
@@ -755,6 +762,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_WATCHDOG_MODEL_IB700:
case VIR_DOMAIN_WATCHDOG_MODEL_DIAG288:
case VIR_DOMAIN_WATCHDOG_MODEL_LAST:
+ default:
return 0;
}
@@ -775,6 +783,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
case VIR_DOMAIN_VIDEO_TYPE_GOP:
case VIR_DOMAIN_VIDEO_TYPE_LAST:
+ default:
return 0;
}
@@ -791,6 +800,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_INPUT_BUS_XEN:
case VIR_DOMAIN_INPUT_BUS_PARALLELS:
case VIR_DOMAIN_INPUT_BUS_LAST:
+ default:
return 0;
}
@@ -806,6 +816,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
+ default:
return 0;
}
--
2.16.1
6 years, 9 months
[libvirt] [PATCH] qemu: Check for down limit of SLIRP prefix too
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1515533
We're already checking if IPv4 prefix isn't too long. But we are
not checking if it isn't too short. QEMU supports prefixes longer
than 4 (including). I haven't find anything similar related to
IPv6 in qemu sources.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_domain.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index df433c2f0..4fc4db68b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3744,6 +3744,12 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
_("prefix too long"));
return -1;
}
+
+ if (ip->prefix < 4) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("prefix too short"));
+ return -1;
+ }
}
if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6)) {
--
2.13.6
6 years, 9 months