[libvirt PATCH 0/2] meson: Enable ZFS storage backend even more often
by Andrea Bolognani
And drop some useless code.
Andrea Bolognani (2):
meson: Enable ZFS storage backend even more often
meson: Stop looking up ZFS programs at build time
meson.build | 16 ----------------
src/storage/storage_backend_zfs.c | 3 +++
2 files changed, 3 insertions(+), 16 deletions(-)
--
2.31.1
3 years, 1 month
[libvirt PATCH 0/7] qemu: retire QEMU_CAPS_SPICE_UNIX
by Ján Tomko
One less thing to probe via query-command-line-options
Ján Tomko (7):
tests: remove disks from spice tests
tests: qemuxml2xmltest: move graphics-spice-timeout
tests: qemuxml2xml: use latest caps for spice tests
tests: qemuxml2argv: use latest caps for spice tests
tests: convert name-escape to use real caps
qemu: always assume QEMU_CAPS_SPICE_UNIX
qemu: retire QEMU_CAPS_SPICE_UNIX
src/qemu/qemu_capabilities.c | 3 +-
src/qemu/qemu_capabilities.h | 2 +-
src/qemu/qemu_validate.c | 10 +--
.../caps_2.11.0.x86_64.xml | 1 -
.../caps_2.12.0.x86_64.xml | 1 -
.../caps_3.0.0.x86_64.xml | 1 -
.../caps_3.1.0.x86_64.xml | 1 -
.../caps_4.0.0.riscv32.xml | 1 -
.../caps_4.0.0.riscv64.xml | 1 -
.../caps_4.0.0.x86_64.xml | 1 -
.../caps_4.1.0.x86_64.xml | 1 -
.../caps_4.2.0.x86_64.xml | 1 -
.../caps_5.0.0.riscv64.xml | 1 -
.../caps_5.0.0.x86_64.xml | 1 -
.../qemucapabilitiesdata/caps_5.1.0.sparc.xml | 1 -
.../caps_5.1.0.x86_64.xml | 1 -
.../caps_5.2.0.riscv64.xml | 1 -
.../caps_5.2.0.x86_64.xml | 1 -
.../caps_6.0.0.x86_64.xml | 1 -
.../caps_6.1.0.x86_64.xml | 1 -
.../caps_6.2.0.aarch64.xml | 1 -
.../caps_6.2.0.x86_64.xml | 1 -
.../graphics-spice-agent-file-xfer.args | 34 ---------
...s-spice-agent-file-xfer.x86_64-latest.args | 35 +++++++++
.../graphics-spice-agent-file-xfer.xml | 5 --
.../graphics-spice-agentmouse.args | 36 ---------
...aphics-spice-agentmouse.x86_64-latest.args | 37 +++++++++
.../graphics-spice-agentmouse.xml | 5 --
...-spice-auto-socket-cfg.x86_64-latest.args} | 17 +++--
...hics-spice-auto-socket.x86_64-latest.args} | 17 +++--
.../graphics-spice-compression.args | 34 ---------
...phics-spice-compression.x86_64-latest.args | 35 +++++++++
.../graphics-spice-compression.xml | 5 --
.../graphics-spice-egl-headless.args | 34 ---------
...hics-spice-egl-headless.x86_64-latest.args | 35 +++++++++
.../graphics-spice-egl-headless.xml | 5 --
.../graphics-spice-invalid-egl-headless.xml | 5 --
.../graphics-spice-no-args.args | 31 --------
.../graphics-spice-no-args.x86_64-latest.args | 34 +++++++++
.../graphics-spice-qxl-vga.args | 34 ---------
.../graphics-spice-qxl-vga.x86_64-latest.args | 35 +++++++++
.../graphics-spice-qxl-vga.xml | 5 --
.../qemuxml2argvdata/graphics-spice-sasl.args | 34 ---------
.../graphics-spice-sasl.x86_64-latest.args | 35 +++++++++
.../qemuxml2argvdata/graphics-spice-sasl.xml | 6 --
.../graphics-spice-socket.args | 30 --------
.../graphics-spice-socket.x86_64-latest.args | 33 ++++++++
.../graphics-spice-timeout.args | 40 ----------
.../graphics-spice-timeout.x86_64-latest.args | 38 ++++++++++
.../graphics-spice-timeout.xml | 13 ----
.../graphics-spice-usb-redir.args | 38 ----------
...raphics-spice-usb-redir.x86_64-latest.args | 41 ++++++++++
tests/qemuxml2argvdata/graphics-spice.args | 34 ---------
.../graphics-spice.x86_64-latest.args | 35 +++++++++
tests/qemuxml2argvdata/graphics-spice.xml | 5 --
...pe.args => name-escape.x86_64-2.11.0.args} | 7 +-
.../name-escape.x86_64-latest.args | 50 ++++++++++++
tests/qemuxml2argvtest.c | 76 ++++---------------
...s-spice-auto-socket-cfg.x86_64-latest.xml} | 5 +-
...phics-spice-auto-socket.x86_64-latest.xml} | 5 +-
...phics-spice-compression.x86_64-latest.xml} | 11 +--
...hics-spice-egl-headless.x86_64-latest.xml} | 11 +--
... graphics-spice-qxl-vga.x86_64-latest.xml} | 11 +--
...> graphics-spice-socket.x86_64-latest.xml} | 5 +-
... graphics-spice-timeout.x86_64-latest.xml} | 15 +---
...e.xml => graphics-spice.x86_64-latest.xml} | 11 +--
tests/qemuxml2xmltest.c | 35 ++-------
67 files changed, 522 insertions(+), 614 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-agent-file-xfer.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-agent-file-xfer.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-agentmouse.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-agentmouse.x86_64-latest.args
rename tests/qemuxml2argvdata/{graphics-spice-auto-socket-cfg.args => graphics-spice-auto-socket-cfg.x86_64-latest.args} (50%)
rename tests/qemuxml2argvdata/{graphics-spice-auto-socket.args => graphics-spice-auto-socket.x86_64-latest.args} (50%)
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-compression.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-compression.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-egl-headless.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-egl-headless.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-no-args.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-no-args.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-qxl-vga.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-qxl-vga.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-sasl.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-sasl.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-socket.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-socket.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-timeout.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-timeout.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice-usb-redir.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice-usb-redir.x86_64-latest.args
delete mode 100644 tests/qemuxml2argvdata/graphics-spice.args
create mode 100644 tests/qemuxml2argvdata/graphics-spice.x86_64-latest.args
rename tests/qemuxml2argvdata/{name-escape.args => name-escape.x86_64-2.11.0.args} (90%)
create mode 100644 tests/qemuxml2argvdata/name-escape.x86_64-latest.args
rename tests/qemuxml2xmloutdata/{graphics-spice-auto-socket-cfg.xml => graphics-spice-auto-socket-cfg.x86_64-latest.xml} (88%)
rename tests/qemuxml2xmloutdata/{graphics-spice-auto-socket.xml => graphics-spice-auto-socket.x86_64-latest.xml} (88%)
rename tests/qemuxml2xmloutdata/{graphics-spice-compression.xml => graphics-spice-compression.x86_64-latest.xml} (86%)
rename tests/qemuxml2xmloutdata/{graphics-spice-egl-headless.xml => graphics-spice-egl-headless.x86_64-latest.xml} (83%)
rename tests/qemuxml2xmloutdata/{graphics-spice-qxl-vga.xml => graphics-spice-qxl-vga.x86_64-latest.xml} (85%)
rename tests/qemuxml2xmloutdata/{graphics-spice-socket.xml => graphics-spice-socket.x86_64-latest.xml} (88%)
rename tests/qemuxml2xmloutdata/{graphics-spice-timeout.xml => graphics-spice-timeout.x86_64-latest.xml} (82%)
rename tests/qemuxml2xmloutdata/{graphics-spice.xml => graphics-spice.x86_64-latest.xml} (87%)
--
2.31.1
3 years, 1 month
[PATCH 0/5] Various cleanups
by Michal Privoznik
I've been playing with cocci lately and noticed it had troubles parsing
some files. When I looked into them I had trouble parsing them as well.
Michal Prívozník (5):
node_device_conf: Bring variables into loops
virpcivpd: Bring variables into loops
virpcivpdtest: Declare variables at multiple lines
lib: Use G_N_ELEMENTS instead of sizeof()/sizeof()
scripts: Properly declare g_auto() stub for cocci
scripts/cocci-macro-file.h | 2 +-
src/conf/node_device_conf.c | 46 +++++++++++++---------------------
src/libxl/libxl_capabilities.c | 2 +-
src/util/virpcivpd.c | 19 +++-----------
tests/virpcimock.c | 2 +-
tests/virpcivpdtest.c | 29 ++++++++++-----------
6 files changed, 39 insertions(+), 61 deletions(-)
--
2.32.0
3 years, 1 month
[libvirt PATCH] tests: qemuxml2argv: remove validation warning
by Ján Tomko
This warning is emitted for pretty much every test case,
making it hard to see what the actual error is.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tests/qemuxml2argvtest.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 804f01fb01..f7ae792371 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -527,8 +527,6 @@ testCompareXMLToArgvValidateSchemaCommand(GStrv args,
}
if (*curargs != '{') {
- VIR_TEST_DEBUG("skipping validation of '%s': argument is not JSON",
- command->name);
arg++;
break;
}
--
2.31.1
3 years, 1 month
[PATCH] lib: Introduce and use g_autoptr() for virInterfaceDef
by Michal Privoznik
There are a lot of places where we call virInterfaceDefFree()
explicitly. We can define autoptr cleanup macro and annotate
declarations with g_autoptr() and remove plenty of those explicit
free calls.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/interface_conf.c | 32 ++++++++---------
src/conf/interface_conf.h | 1 +
src/conf/virinterfaceobj.c | 3 +-
src/interface/interface_backend_netcf.c | 47 ++++++++-----------------
src/interface/interface_backend_udev.c | 29 +++++----------
src/test/test_driver.c | 17 ++++-----
tests/interfacexml2xmltest.c | 17 ++++-----
7 files changed, 53 insertions(+), 93 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index b45dc37379..f2b3804bec 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -679,7 +679,7 @@ static virInterfaceDef *
virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
int parentIfType)
{
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
int type;
char *tmp;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
@@ -716,28 +716,28 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_XML_ERROR,
_("interface has unsupported type '%s'"),
virInterfaceTypeToString(type));
- goto error;
+ return NULL;
}
def->type = type;
if (virInterfaceDefParseName(def, ctxt) < 0)
- goto error;
+ return NULL;
if (parentIfType == VIR_INTERFACE_TYPE_LAST) {
/* only recognize these in toplevel bond interfaces */
if (virInterfaceDefParseStartMode(def, ctxt) < 0)
- goto error;
+ return NULL;
if (virInterfaceDefParseMtu(def, ctxt) < 0)
- goto error;
+ return NULL;
if (virInterfaceDefParseIfAdressing(def, ctxt) < 0)
- goto error;
+ return NULL;
}
if (type != VIR_INTERFACE_TYPE_BRIDGE) {
/* link status makes no sense for a bridge */
lnk = virXPathNode("./link", ctxt);
if (lnk && virInterfaceLinkParseXML(lnk, &def->lnk) < 0)
- goto error;
+ return NULL;
}
switch (type) {
@@ -751,11 +751,11 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
if (!(bridge = virXPathNode("./bridge[1]", ctxt))) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bridge interface misses the bridge element"));
- goto error;
+ return NULL;
}
ctxt->node = bridge;
if (virInterfaceDefParseBridge(def, ctxt) < 0)
- goto error;
+ return NULL;
break;
}
case VIR_INTERFACE_TYPE_BOND: {
@@ -764,11 +764,11 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
if (!(bond = virXPathNode("./bond[1]", ctxt))) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("bond interface misses the bond element"));
- goto error;
+ return NULL;
}
ctxt->node = bond;
if (virInterfaceDefParseBond(def, ctxt) < 0)
- goto error;
+ return NULL;
break;
}
case VIR_INTERFACE_TYPE_VLAN: {
@@ -777,21 +777,17 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
if (!(vlan = virXPathNode("./vlan[1]", ctxt))) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("vlan interface misses the vlan element"));
- goto error;
+ return NULL;
}
ctxt->node = vlan;
if (virInterfaceDefParseVlan(def, ctxt) < 0)
- goto error;
+ return NULL;
break;
}
}
- return def;
-
- error:
- virInterfaceDefFree(def);
- return NULL;
+ return g_steal_pointer(&def);
}
diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h
index ea92e0fb31..510d83b2bf 100644
--- a/src/conf/interface_conf.h
+++ b/src/conf/interface_conf.h
@@ -153,6 +153,7 @@ struct _virInterfaceDef {
void
virInterfaceDefFree(virInterfaceDef *def);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virInterfaceDef, virInterfaceDefFree);
virInterfaceDef *
virInterfaceDefParseString(const char *xmlStr,
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index 9439bb3d0b..ceb3ae7595 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -362,7 +362,7 @@ virInterfaceObjListCloneCb(void *payload,
virInterfaceObj *srcObj = payload;
struct _virInterfaceObjListCloneData *data = opaque;
char *xml = NULL;
- virInterfaceDef *backup = NULL;
+ g_autoptr(virInterfaceDef) backup = NULL;
virInterfaceObj *obj;
if (data->error)
@@ -387,7 +387,6 @@ virInterfaceObjListCloneCb(void *payload,
error:
data->error = true;
VIR_FREE(xml);
- virInterfaceDefFree(backup);
virObjectUnlock(srcObj);
return 0;
}
diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index 78fd4f9bc7..146a703953 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -387,7 +387,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
}
for (i = 0; i < count; i++) {
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
struct netcf_if *iface;
iface = ncf_lookup_by_name(driver->netcf, names[i]);
@@ -416,11 +416,8 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
}
ncf_if_free(iface);
- if (!filter(conn, def)) {
- virInterfaceDefFree(def);
+ if (!filter(conn, def))
continue;
- }
- virInterfaceDefFree(def);
want++;
}
@@ -481,7 +478,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
}
for (i = 0; i < count && want < nnames; i++) {
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
struct netcf_if *iface;
iface = ncf_lookup_by_name(driver->netcf, allnames[i]);
@@ -510,11 +507,8 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
}
ncf_if_free(iface);
- if (!filter(conn, def)) {
- virInterfaceDefFree(def);
+ if (!filter(conn, def))
continue;
- }
- virInterfaceDefFree(def);
names[want++] = g_steal_pointer(&allnames[i]);
}
@@ -665,7 +659,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
tmp_iface_objs = g_new0(virInterfacePtr, count + 1);
for (i = 0; i < count; i++) {
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
iface = ncf_lookup_by_name(driver->netcf, names[i]);
if (!iface) {
@@ -693,20 +687,17 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
if (!virConnectListAllInterfacesCheckACL(conn, def)) {
ncf_if_free(iface);
iface = NULL;
- virInterfaceDefFree(def);
continue;
}
if (ifaces) {
- if (!(iface_obj = virGetInterface(conn, def->name, def->mac))) {
- virInterfaceDefFree(def);
+ if (!(iface_obj = virGetInterface(conn, def->name, def->mac)))
goto cleanup;
- }
+
tmp_iface_objs[niface_objs] = iface_obj;
}
niface_objs++;
- virInterfaceDefFree(def);
ncf_if_free(iface);
iface = NULL;
}
@@ -743,7 +734,7 @@ static virInterfacePtr netcfInterfaceLookupByName(virConnectPtr conn,
{
struct netcf_if *iface;
virInterfacePtr ret = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
virObjectLock(driver);
iface = ncf_lookup_by_name(driver->netcf, name);
@@ -772,7 +763,6 @@ static virInterfacePtr netcfInterfaceLookupByName(virConnectPtr conn,
cleanup:
ncf_if_free(iface);
- virInterfaceDefFree(def);
virObjectUnlock(driver);
return ret;
}
@@ -783,7 +773,7 @@ static virInterfacePtr netcfInterfaceLookupByMACString(virConnectPtr conn,
struct netcf_if *iface;
int niface;
virInterfacePtr ret = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
virObjectLock(driver);
niface = ncf_lookup_by_mac_string(driver->netcf, macstr, 1, &iface);
@@ -820,7 +810,6 @@ static virInterfacePtr netcfInterfaceLookupByMACString(virConnectPtr conn,
cleanup:
ncf_if_free(iface);
- virInterfaceDefFree(def);
virObjectUnlock(driver);
return ret;
}
@@ -830,7 +819,7 @@ static char *netcfInterfaceGetXMLDesc(virInterfacePtr ifinfo,
{
struct netcf_if *iface = NULL;
char *xmlstr = NULL;
- virInterfaceDef *ifacedef = NULL;
+ g_autoptr(virInterfaceDef) ifacedef = NULL;
char *ret = NULL;
bool active;
@@ -880,7 +869,6 @@ static char *netcfInterfaceGetXMLDesc(virInterfacePtr ifinfo,
cleanup:
ncf_if_free(iface);
VIR_FREE(xmlstr);
- virInterfaceDefFree(ifacedef);
virObjectUnlock(driver);
return ret;
}
@@ -891,7 +879,7 @@ static virInterfacePtr netcfInterfaceDefineXML(virConnectPtr conn,
{
struct netcf_if *iface = NULL;
char *xmlstr = NULL;
- virInterfaceDef *ifacedef = NULL;
+ g_autoptr(virInterfaceDef) ifacedef = NULL;
virInterfacePtr ret = NULL;
virCheckFlags(VIR_INTERFACE_DEFINE_VALIDATE, NULL);
@@ -929,7 +917,6 @@ static virInterfacePtr netcfInterfaceDefineXML(virConnectPtr conn,
cleanup:
ncf_if_free(iface);
VIR_FREE(xmlstr);
- virInterfaceDefFree(ifacedef);
virObjectUnlock(driver);
return ret;
}
@@ -937,7 +924,7 @@ static virInterfacePtr netcfInterfaceDefineXML(virConnectPtr conn,
static int netcfInterfaceUndefine(virInterfacePtr ifinfo)
{
struct netcf_if *iface = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
int ret = -1;
virObjectLock(driver);
@@ -968,7 +955,6 @@ static int netcfInterfaceUndefine(virInterfacePtr ifinfo)
cleanup:
ncf_if_free(iface);
- virInterfaceDefFree(def);
virObjectUnlock(driver);
return ret;
}
@@ -977,7 +963,7 @@ static int netcfInterfaceCreate(virInterfacePtr ifinfo,
unsigned int flags)
{
struct netcf_if *iface = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
int ret = -1;
bool active;
@@ -1020,7 +1006,6 @@ static int netcfInterfaceCreate(virInterfacePtr ifinfo,
cleanup:
ncf_if_free(iface);
- virInterfaceDefFree(def);
virObjectUnlock(driver);
return ret;
}
@@ -1029,7 +1014,7 @@ static int netcfInterfaceDestroy(virInterfacePtr ifinfo,
unsigned int flags)
{
struct netcf_if *iface = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
int ret = -1;
bool active;
@@ -1072,7 +1057,6 @@ static int netcfInterfaceDestroy(virInterfacePtr ifinfo,
cleanup:
ncf_if_free(iface);
- virInterfaceDefFree(def);
virObjectUnlock(driver);
return ret;
}
@@ -1080,7 +1064,7 @@ static int netcfInterfaceDestroy(virInterfacePtr ifinfo,
static int netcfInterfaceIsActive(virInterfacePtr ifinfo)
{
struct netcf_if *iface = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
int ret = -1;
bool active;
@@ -1105,7 +1089,6 @@ static int netcfInterfaceIsActive(virInterfacePtr ifinfo)
cleanup:
ncf_if_free(iface);
- virInterfaceDefFree(def);
virObjectUnlock(driver);
return ret;
}
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 0217f16607..8c417714e5 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -165,7 +165,7 @@ udevNumOfInterfacesByStatus(virConnectPtr conn, virUdevStatus status,
udev_list_entry_foreach(dev_entry, devices) {
struct udev_device *dev;
const char *path;
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
path = udev_list_entry_get_name(dev_entry);
dev = udev_device_new_from_syspath(udev, path);
@@ -174,7 +174,6 @@ udevNumOfInterfacesByStatus(virConnectPtr conn, virUdevStatus status,
if (filter(conn, def))
count++;
udev_device_unref(dev);
- virInterfaceDefFree(def);
}
cleanup:
@@ -218,7 +217,7 @@ udevListInterfacesByStatus(virConnectPtr conn,
udev_list_entry_foreach(dev_entry, devices) {
struct udev_device *dev;
const char *path;
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
/* Ensure we won't exceed the size of our array */
if (count > names_len)
@@ -233,7 +232,6 @@ udevListInterfacesByStatus(virConnectPtr conn,
count++;
}
udev_device_unref(dev);
- virInterfaceDefFree(def);
}
udev_enumerate_unref(enumerate);
@@ -355,7 +353,7 @@ udevConnectListAllInterfaces(virConnectPtr conn,
const char *path;
const char *name;
const char *macaddr;
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
path = udev_list_entry_get_name(dev_entry);
dev = udev_device_new_from_syspath(udev, path);
@@ -366,10 +364,8 @@ udevConnectListAllInterfaces(virConnectPtr conn,
def = udevGetMinimalDefForDevice(dev);
if (!virConnectListAllInterfacesCheckACL(conn, def)) {
udev_device_unref(dev);
- virInterfaceDefFree(def);
continue;
}
- virInterfaceDefFree(def);
/* Filter the results */
if (MATCH(VIR_CONNECT_LIST_INTERFACES_FILTERS_ACTIVE) &&
@@ -413,7 +409,7 @@ udevInterfaceLookupByName(virConnectPtr conn, const char *name)
struct udev *udev = udev_ref(driver->udev);
struct udev_device *dev;
virInterfacePtr ret = NULL;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
/* get a device reference based on the device name */
dev = udev_device_new_from_subsystem_sysname(udev, "net", name);
@@ -435,7 +431,6 @@ udevInterfaceLookupByName(virConnectPtr conn, const char *name)
cleanup:
udev_unref(udev);
- virInterfaceDefFree(def);
return ret;
}
@@ -447,7 +442,7 @@ udevInterfaceLookupByMACString(virConnectPtr conn, const char *macstr)
struct udev_enumerate *enumerate = NULL;
struct udev_list_entry *dev_entry;
struct udev_device *dev;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
virInterfacePtr ret = NULL;
enumerate = udevGetDevices(udev, VIR_UDEV_IFACE_ALL);
@@ -499,7 +494,6 @@ udevInterfaceLookupByMACString(virConnectPtr conn, const char *macstr)
if (enumerate)
udev_enumerate_unref(enumerate);
udev_unref(udev);
- virInterfaceDefFree(def);
return ret;
}
@@ -945,7 +939,7 @@ static virInterfaceDef * ATTRIBUTE_NONNULL(1)
udevGetIfaceDef(struct udev *udev, const char *name)
{
struct udev_device *dev = NULL;
- virInterfaceDef *ifacedef;
+ g_autoptr(virInterfaceDef) ifacedef = NULL;
unsigned int mtu;
const char *mtu_str;
char *vlan_parent_dev = NULL;
@@ -1038,13 +1032,11 @@ udevGetIfaceDef(struct udev *udev, const char *name)
udev_device_unref(dev);
- return ifacedef;
+ return g_steal_pointer(&ifacedef);
error:
udev_device_unref(dev);
- virInterfaceDefFree(ifacedef);
-
return NULL;
}
@@ -1053,7 +1045,7 @@ udevInterfaceGetXMLDesc(virInterfacePtr ifinfo,
unsigned int flags)
{
struct udev *udev = udev_ref(driver->udev);
- virInterfaceDef *ifacedef;
+ g_autoptr(virInterfaceDef) ifacedef = NULL;
char *xmlstr = NULL;
virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL);
@@ -1071,8 +1063,6 @@ udevInterfaceGetXMLDesc(virInterfacePtr ifinfo,
xmlstr = virInterfaceDefFormat(ifacedef);
- virInterfaceDefFree(ifacedef);
-
cleanup:
/* decrement our udev ptr */
udev_unref(udev);
@@ -1085,7 +1075,7 @@ udevInterfaceIsActive(virInterfacePtr ifinfo)
{
struct udev *udev = udev_ref(driver->udev);
struct udev_device *dev;
- virInterfaceDef *def = NULL;
+ g_autoptr(virInterfaceDef) def = NULL;
int status = -1;
dev = udev_device_new_from_subsystem_sysname(udev, "net",
@@ -1110,7 +1100,6 @@ udevInterfaceIsActive(virInterfacePtr ifinfo)
cleanup:
udev_unref(udev);
- virInterfaceDefFree(def);
return status;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 13d07e570e..ea474d55ac 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1096,7 +1096,7 @@ testParseNetworks(testDriver *privconn,
return -1;
for (i = 0; i < num; i++) {
- virNetworkDef *def;
+ g_autoptr(virNetworkDef) def = NULL;
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file, "network");
if (!node)
return -1;
@@ -1105,10 +1105,9 @@ testParseNetworks(testDriver *privconn,
if (!def)
return -1;
- if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 0))) {
- virNetworkDefFree(def);
+ if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 0)))
return -1;
- }
+ def = NULL;
virNetworkObjSetActive(obj, true);
virNetworkObjEndAPI(&obj);
@@ -1133,7 +1132,7 @@ testParseInterfaces(testDriver *privconn,
return -1;
for (i = 0; i < num; i++) {
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
"interface");
if (!node)
@@ -1143,10 +1142,9 @@ testParseInterfaces(testDriver *privconn,
if (!def)
return -1;
- if (!(obj = virInterfaceObjListAssignDef(privconn->ifaces, def))) {
- virInterfaceDefFree(def);
+ if (!(obj = virInterfaceObjListAssignDef(privconn->ifaces, def)))
return -1;
- }
+ def = NULL;
virInterfaceObjSetActive(obj, true);
virInterfaceObjEndAPI(&obj);
@@ -6195,7 +6193,7 @@ testInterfaceDefineXML(virConnectPtr conn,
unsigned int flags)
{
testDriver *privconn = conn->privateData;
- virInterfaceDef *def;
+ g_autoptr(virInterfaceDef) def = NULL;
virInterfaceObj *obj = NULL;
virInterfaceDef *objdef;
virInterfacePtr ret = NULL;
@@ -6214,7 +6212,6 @@ testInterfaceDefineXML(virConnectPtr conn,
ret = virGetInterface(conn, objdef->name, objdef->mac);
cleanup:
- virInterfaceDefFree(def);
virInterfaceObjEndAPI(&obj);
virObjectUnlock(privconn);
return ret;
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c
index 8235e701a9..15fab88107 100644
--- a/tests/interfacexml2xmltest.c
+++ b/tests/interfacexml2xmltest.c
@@ -18,28 +18,23 @@ testCompareXMLToXMLFiles(const char *xml)
{
g_autofree char *xmlData = NULL;
g_autofree char *actual = NULL;
- int ret = -1;
- virInterfaceDef *dev = NULL;
+ g_autoptr(virInterfaceDef) dev = NULL;
if (virTestLoadFile(xml, &xmlData) < 0)
- goto fail;
+ return -1;
if (!(dev = virInterfaceDefParseString(xmlData, 0)))
- goto fail;
+ return -1;
if (!(actual = virInterfaceDefFormat(dev)))
- goto fail;
+ return -1;
if (STRNEQ(xmlData, actual)) {
virTestDifferenceFull(stderr, xmlData, xml, actual, NULL);
- goto fail;
+ return -1;
}
- ret = 0;
-
- fail:
- virInterfaceDefFree(dev);
- return ret;
+ return 0;
}
static int
--
2.32.0
3 years, 1 month
Re: Re: for rbd, how to use qmp directly to add dick
by Peter Krempa
On Tue, Nov 02, 2021 at 12:28:29 +0800, longguang.yue wrote:
Firstly I'd like to ask you to follow mailing list posting netiquette
and don't drop the mailing list on replies from the CC list. My reply
would then not end up in the archives and the community would not be
able to refer to it later.
> i use kata on kubernetes. kata manages qemu via qmp directly.
So this makes this out of scope for libvirt. A better forum to ask
qemu-only related questions is the qemu mailing list.
You can also make this a case for the Kata community to adopt usage of
libvirt, as libvirt gives you a stable, secure and tested way to manage
a qemu process. I think the Kata project would benefit from libvirt
usage and could focus their efforts on adding features rather than
reinventing what libvirt has for a long time already.
> suppose secret object does not have keyid and iv, can i store base64-coded ceph-auth-ring into data?
> could you tell me a complete command to add rbd disk ? no encrypt
Note that would be insecure as anybody with access to the host could
read the commandline and know your secret.
Let's rephrase your question to: "How does libvirt securely pass
passwords to qemu on the commandline?"
Libvirt uses two kinds of secrets, which both are secure when used
properly:
(Note that libvirt nowadays uses direct JSON with -object as it's
possible starting with qemu-6.0, thus my examples will use the new
format)
1) Secret stored in a file:
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}'
libvirt uses this format to pass the master key, which is used to
encrypt other secrets, but any other secret can be passed this way. It's
a bit tedious, and that's the reason why libvirt passes only the master
key using the file.
When the access permissions are set properly this way is secure.
2) Inline (base64) encrypted secrets
-object '{"qom-type":"secret","id":"libvirt-5-storage-auth-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwU6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}'
This secret is encrypted using the master key (as you can see above).
When inspecting the commandline an attacker can't tell the original
value.
Theoretically when using the monitor (QMP) it's also secure to pass a
plaintext secret, but that's tricky if the monitor traffic is logged, so
libvirt opted to use encrypted secrets also in that case.
For any other use please refer to the qemu documentation:
https://gitlab.com/qemu-project/qemu/-/blob/master/qapi/crypto.json#L386
The above direct link describes how to use the secret object.
(I'm deliberately not showing the insecure usage so that it's not
getting copied around).
3 years, 1 month
[PATCH 0/9] Configurable policy for handling unstable interfaces
by Markus Armbruster
Option -compat lets you configure what to do when deprecated
interfaces get used. This series extends this to unstable interfaces.
Works the same way. Intended for testing users of the management
interfaces. It is experimental.
To make it possible, I replace the "x-" naming convention by special
feature flag "unstable". See PATCH 1 for rationale.
Based on my "[PATCH v4 0/5] qapi: Add feature flags to enum members"
Based-on: Message-Id: <20211025042405.3762351-1-armbru(a)redhat.com>
Markus Armbruster (9):
qapi: New special feature flag "unstable"
qapi: Mark unstable QMP parts with feature 'unstable'
qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
qapi: Tools for sets of special feature flags in generated code
qapi: Generalize struct member policy checking
qapi: Generalize command policy checking
qapi: Generalize enum member policy checking
qapi: Factor out compat_policy_input_ok()
qapi: Extend -compat to set policy for unstable interfaces
docs/devel/qapi-code-gen.rst | 9 +-
qapi/block-core.json | 123 +++++++++++++++++-------
qapi/compat.json | 6 +-
qapi/migration.json | 35 +++++--
qapi/misc.json | 6 +-
qapi/qom.json | 11 ++-
include/qapi/compat-policy.h | 7 ++
include/qapi/qmp/dispatch.h | 6 +-
include/qapi/util.h | 8 +-
include/qapi/visitor-impl.h | 6 +-
include/qapi/visitor.h | 17 +++-
monitor/misc.c | 7 +-
qapi/qapi-forward-visitor.c | 16 +--
qapi/qapi-visit-core.c | 41 ++++----
qapi/qmp-dispatch.c | 57 ++++++++---
qapi/qmp-registry.c | 4 +-
qapi/qobject-input-visitor.c | 22 ++---
qapi/qobject-output-visitor.c | 13 ++-
storage-daemon/qemu-storage-daemon.c | 3 +-
qapi/trace-events | 4 +-
qemu-options.hx | 20 +++-
scripts/qapi/commands.py | 12 +--
scripts/qapi/events.py | 10 +-
scripts/qapi/gen.py | 13 +++
scripts/qapi/schema.py | 11 ++-
scripts/qapi/types.py | 22 +++--
scripts/qapi/visit.py | 14 +--
tests/qapi-schema/qapi-schema-test.json | 7 +-
tests/qapi-schema/qapi-schema-test.out | 5 +
29 files changed, 353 insertions(+), 162 deletions(-)
--
2.31.1
3 years, 1 month