[PATCH 0/2] tools: A few small fixes for virt-qemu-sev-validate
by Jim Fehlig
See patches for details.
Jim Fehlig (2):
docs: Fix examples in virt-qemu-sev-validate man page
tools: Fix detection of remote libvirt access in
virt-qemu-sev-validate
docs/manpages/virt-qemu-sev-validate.rst | 24 ++++++++++++------------
tools/virt-qemu-sev-validate | 2 +-
2 files changed, 13 insertions(+), 13 deletions(-)
--
2.38.1
1 year, 10 months
[PATCH 0/7] Remove last instances of looped XML element lookup from domain_conf.c
by Peter Krempa
Had this around for a while but it needed some finishing touches.
This ousts the last loop-based XML parser iterating over XML nodes and
replaces it by something more modern, fixing a few bugs i the process
and cleaning stuff up.
There are a few of such parsers still around e.g in the network XML
parsing part.
Peter Krempa (7):
virPCIDeviceAddressParseXML: Use virXMLNodeGetSubelement to find
'zpci'
virNetDevVPortProfileParse: Use virXMLNodeGetSubelement to find
'<parameters>'
virNetworkDHCPRangeDefParseXML: Use virXMLNodeGetSubelement to find
'lease'
virNetworkDHCPHostDefParseXML: Use virXMLNodeGetSubelement to find
'lease'
virBitmapIsBitSet: Allow NULL bitmap
qemustatusxml2xmltest: Add test data for testing '<origstates>' of PCI
hostdev
conf: Store 'origstates' of PCI hostdevs in a bitmap
src/conf/device_conf.c | 16 +---
src/conf/domain_conf.c | 97 +++++++++++------------
src/conf/domain_conf.h | 31 +++-----
src/conf/netdev_vport_profile_conf.c | 20 ++---
src/conf/network_conf.c | 28 ++-----
src/conf/virconftypes.h | 2 -
src/hypervisor/virhostdev.c | 25 +++---
src/util/virbitmap.c | 4 +-
src/util/virbitmap.h | 2 +-
tests/qemustatusxml2xmldata/modern-in.xml | 12 +++
10 files changed, 107 insertions(+), 130 deletions(-)
--
2.39.1
1 year, 10 months
[libvirt PATCH] tools: use g_autofree more
by Ján Tomko
Remove some obvious uses of VIR_FREE in favor of automatic cleanup.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tools/virsh-domain-monitor.c | 5 +----
tools/virsh-domain.c | 37 +++++++++----------------------
tools/virsh-network.c | 6 ++---
tools/virsh-nwfilter.c | 3 +--
tools/virt-admin.c | 13 ++++-------
tools/virt-host-validate-common.c | 6 ++---
6 files changed, 20 insertions(+), 50 deletions(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index f89118f64f..c2134faba1 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1213,7 +1213,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virDomainInfo info;
g_autoptr(virshDomain) dom = NULL;
virSecurityModel secmodel;
- virSecurityLabelPtr seclabel;
int persistent = 0;
bool ret = true;
int autostart;
@@ -1301,6 +1300,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
} else {
/* Only print something if a security model is active */
if (secmodel.model[0] != '\0') {
+ g_autofree virSecurityLabelPtr seclabel = NULL;
vshPrint(ctl, "%-15s %s\n", _("Security model:"), secmodel.model);
vshPrint(ctl, "%-15s %s\n", _("Security DOI:"), secmodel.doi);
@@ -1308,15 +1308,12 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
seclabel = g_new0(virSecurityLabel, 1);
if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
- VIR_FREE(seclabel);
return false;
} else {
if (seclabel->label[0] != '\0')
vshPrint(ctl, "%-15s %s (%s)\n", _("Security label:"),
seclabel->label, seclabel->enforcing ? "enforcing" : "permissive");
}
-
- VIR_FREE(seclabel);
}
}
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 59b2b3ce60..a4abcb1b03 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -366,7 +366,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
- char *buffer;
+ g_autofree char *buffer = NULL;
int rv;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
@@ -404,8 +404,6 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
else
rv = virDomainAttachDevice(dom, buffer);
- VIR_FREE(buffer);
-
if (rv < 0) {
vshError(ctl, _("Failed to attach device from %s"), from);
return false;
@@ -2364,7 +2362,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
const char *path = NULL;
int abort_flags = 0;
const char *xml = NULL;
- char *xmlstr = NULL;
+ g_autofree char *xmlstr = NULL;
bool print_xml = vshCommandOptBool(cmd, "print-xml");
virTypedParameterPtr params = NULL;
virshBlockJobWaitData *bjWait = NULL;
@@ -2567,7 +2565,6 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
ret = true;
cleanup:
- VIR_FREE(xmlstr);
virTypedParamsFree(params, nparams);
virshBlockJobWaitFree(bjWait);
return ret;
@@ -5624,7 +5621,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
bool ret = false;
bool created = false;
bool generated = false;
- char *mime = NULL;
+ g_autofree char *mime = NULL;
virshControl *priv = ctl->privData;
virshStreamCallbackData cbdata;
@@ -5688,7 +5685,6 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
unlink(file);
if (generated)
VIR_FREE(file);
- VIR_FREE(mime);
return ret;
}
@@ -7432,9 +7428,8 @@ cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
}
@@ -8305,7 +8300,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
const char *from = NULL;
- char *buffer;
+ g_autofree char *buffer = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
@@ -8322,7 +8317,6 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
dom = virDomainDefineXMLFlags(priv->conn, buffer, flags);
else
dom = virDomainDefineXML(priv->conn, buffer);
- VIR_FREE(buffer);
if (!dom) {
vshError(ctl, _("Failed to define domain from %s"), from);
@@ -10340,7 +10334,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshDomain) dom = NULL;
bool ret = false;
- char *guest_agent_cmd = NULL;
+ g_autofree char *guest_agent_cmd = NULL;
char *result = NULL;
int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT;
int judge = 0;
@@ -10405,7 +10399,6 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
cleanup:
VIR_FREE(result);
- VIR_FREE(guest_agent_cmd);
return ret;
}
@@ -11185,7 +11178,7 @@ doMigrate(void *opaque)
if (vshCommandOptStringReq(ctl, cmd, "migrate-disks", &opt) < 0)
goto out;
if (opt) {
- char **val = NULL;
+ g_autofree char **val = NULL;
val = g_strsplit(opt, ",", 0);
@@ -11194,28 +11187,22 @@ doMigrate(void *opaque)
&maxparams,
VIR_MIGRATE_PARAM_MIGRATE_DISKS,
(const char **)val) < 0) {
- VIR_FREE(val);
goto save_error;
}
-
- VIR_FREE(val);
}
if (vshCommandOptStringReq(ctl, cmd, "comp-methods", &opt) < 0)
goto out;
if (opt) {
- char **val = g_strsplit(opt, ",", 0);
+ g_autofree char **val = g_strsplit(opt, ",", 0);
if (virTypedParamsAddStringList(¶ms,
&nparams,
&maxparams,
VIR_MIGRATE_PARAM_COMPRESSION,
(const char **)val) < 0) {
- VIR_FREE(val);
goto save_error;
}
-
- VIR_FREE(val);
}
if ((rv = vshCommandOptInt(ctl, cmd, "comp-mt-level", &intOpt)) < 0) {
@@ -11257,7 +11244,7 @@ doMigrate(void *opaque)
if (vshCommandOptStringReq(ctl, cmd, "xml", &opt) < 0)
goto out;
if (opt) {
- char *xml;
+ g_autofree char *xml = NULL;
if (virFileReadAll(opt, VSH_MAX_XML_FILE, &xml) < 0) {
vshError(ctl, _("cannot read file '%s'"), opt);
@@ -11266,16 +11253,14 @@ doMigrate(void *opaque)
if (virTypedParamsAddString(¶ms, &nparams, &maxparams,
VIR_MIGRATE_PARAM_DEST_XML, xml) < 0) {
- VIR_FREE(xml);
goto save_error;
}
- VIR_FREE(xml);
}
if (vshCommandOptStringReq(ctl, cmd, "persistent-xml", &opt) < 0)
goto out;
if (opt) {
- char *xml;
+ g_autofree char *xml = NULL;
if (virFileReadAll(opt, VSH_MAX_XML_FILE, &xml) < 0) {
vshError(ctl, _("cannot read file '%s'"), opt);
@@ -11284,10 +11269,8 @@ doMigrate(void *opaque)
if (virTypedParamsAddString(¶ms, &nparams, &maxparams,
VIR_MIGRATE_PARAM_PERSIST_XML, xml) < 0) {
- VIR_FREE(xml);
goto save_error;
}
- VIR_FREE(xml);
}
if ((rv = vshCommandOptInt(ctl, cmd, "auto-converge-initial", &intOpt)) < 0) {
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 004719dad6..13f2e729eb 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -412,7 +412,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
int autostart;
int persistent = -1;
int active = -1;
- char *bridge = NULL;
+ g_autofree char *bridge = NULL;
if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
return false;
@@ -441,7 +441,6 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
if (bridge)
vshPrint(ctl, "%-15s %s\n", _("Bridge:"), bridge);
- VIR_FREE(bridge);
return true;
}
@@ -1500,7 +1499,7 @@ cmdNetworkPortCreate(vshControl *ctl, const vshCmd *cmd)
virNetworkPortPtr port = NULL;
const char *from = NULL;
bool ret = false;
- char *buffer = NULL;
+ g_autofree char *buffer = NULL;
g_autoptr(virshNetwork) network = NULL;
unsigned int flags = 0;
@@ -1533,7 +1532,6 @@ cmdNetworkPortCreate(vshControl *ctl, const vshCmd *cmd)
ret = true;
cleanup:
- VIR_FREE(buffer);
if (port)
virNetworkPortFree(port);
return ret;
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index d4112c8620..98380b452d 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -516,7 +516,7 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd *cmd)
{
virNWFilterBindingPtr binding;
const char *from = NULL;
- char *buffer;
+ g_autofree char *buffer = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
@@ -530,7 +530,6 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd *cmd)
return false;
binding = virNWFilterBindingCreateXML(priv->conn, buffer, flags);
- VIR_FREE(buffer);
if (!binding) {
vshError(ctl, _("Failed to create network filter from %s"), from);
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index 85b010b95f..8baf9636d3 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -73,7 +73,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUSED,
vshControl *ctl = opaque;
const char *str = "unknown reason";
virErrorPtr error;
- char *uri = NULL;
+ g_autofree char *uri = NULL;
if (reason == VIR_CONNECT_CLOSE_REASON_CLIENT)
return;
@@ -97,8 +97,6 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUSED,
}
vshError(ctl, _(str), NULLSTR(uri));
- VIR_FREE(uri);
-
virErrorRestore(&error);
}
@@ -183,7 +181,7 @@ static const vshCmdInfo info_uri[] = {
static bool
cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
- char *uri;
+ g_autofree char *uri = NULL;
vshAdmControl *priv = ctl->privData;
uri = virAdmConnectGetURI(priv->conn);
@@ -193,7 +191,6 @@ cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
}
vshPrint(ctl, "%s\n", uri);
- VIR_FREE(uri);
return true;
}
@@ -328,7 +325,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
int nsrvs = 0;
size_t i;
bool ret = false;
- char *uri = NULL;
+ g_autofree char *uri = NULL;
virAdmServerPtr *srvs = NULL;
vshAdmControl *priv = ctl->privData;
g_autoptr(vshTable) table = NULL;
@@ -365,7 +362,6 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
virAdmServerFree(srvs[i]);
VIR_FREE(srvs);
}
- VIR_FREE(uri);
return ret;
}
@@ -702,9 +698,8 @@ cmdClientInfo(vshControl *ctl, const vshCmd *cmd)
vshAdmClientTransportToString(virAdmClientGetTransport(clnt)));
for (i = 0; i < nparams; i++) {
- char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+ g_autofree char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
- VIR_FREE(str);
}
ret = true;
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index 2ac96d1e19..a41bb346d2 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -56,7 +56,7 @@ void virHostMsgCheck(const char *prefix,
...)
{
va_list args;
- char *msg;
+ g_autofree char *msg = NULL;
if (quiet)
return;
@@ -66,7 +66,6 @@ void virHostMsgCheck(const char *prefix,
va_end(args);
fprintf(stdout, _("%6s: Checking %-60s: "), prefix, msg);
- VIR_FREE(msg);
}
static bool virHostMsgWantEscape(void)
@@ -114,7 +113,7 @@ void virHostMsgFail(virHostValidateLevel level,
...)
{
va_list args;
- char *msg;
+ g_autofree char *msg = NULL;
if (quiet)
return;
@@ -129,7 +128,6 @@ void virHostMsgFail(virHostValidateLevel level,
else
fprintf(stdout, "%s (%s)\n",
_(failMessages[level]), msg);
- VIR_FREE(msg);
}
--
2.39.0
1 year, 10 months
[PATCH 0/6] Few outstanding XML schema interleaving fixes
by Peter Krempa
Few patches I had in a different branch from my posting in october of
2022.
Peter Krempa (6):
schema: domain: Allow interleave of 'smartcard' subelements
schema: domain: Allow interleaving of elements in 'osxen' definition
schema: domain: Allow interleaving of 'inituser/initgroup' in 'osexe'
definition
schema: nodedev: Allow interleaving of sub-elements of 'device'
schema: nodedev: Allow interneaving sub-elements of 'css' address type
schema: storage: Allow interleaving of 'cipher' and 'ivgen' elements
src/conf/schemas/domaincommon.rng | 140 ++++++++++++++++-------------
src/conf/schemas/nodedev.rng | 103 ++++++++++-----------
src/conf/schemas/storagecommon.rng | 14 +--
3 files changed, 140 insertions(+), 117 deletions(-)
--
2.39.1
1 year, 10 months
[PATCH 0/5] qemu: Don't remove macvtaps on failed start
by Michal Privoznik
See 5/5 for explanation.
Michal Prívozník (5):
domain_conf: Move virDomainNetVhostuserMode enum declaration
domain_conf: Rewrite virDomainChrSourceModeTypeFromString() using
VIR_ENUM_IMPL()
virnetdevmacvlan: Drop G_GNUC_WARN_UNUSED_RESULT annotation for
virNetDevMacVLanDeleteWithVPortProfile()
conf: Format and parse private data for virDomainNetDef
qemu: Don't remove macvtaps on failed start
src/conf/domain_conf.c | 122 +++++++++++++++++++++++++-----------
src/conf/domain_conf.h | 7 +++
src/qemu/qemu_domain.c | 27 ++++++++
src/qemu/qemu_domain.h | 5 ++
src/qemu/qemu_hotplug.c | 22 +++----
src/qemu/qemu_interface.c | 3 +
src/qemu/qemu_process.c | 13 ++--
src/util/virnetdevmacvlan.h | 2 +-
8 files changed, 144 insertions(+), 57 deletions(-)
--
2.39.1
1 year, 10 months
[libvirt PATCH] qemu: fix a typo
by Ján Tomko
s/usw/use/
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
Pushed as trivial
src/qemu/qemu_fd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c
index f5eedb88ec..d613f22032 100644
--- a/src/qemu/qemu_fd.c
+++ b/src/qemu/qemu_fd.c
@@ -100,7 +100,7 @@ qemuFDPassNew(const char *prefix,
* qemuFDPassNewPassed:
* @fdSetID: ID of an FDset which was allready passed to qemu
*
- * Create qemuFDPass pointing to an already passed FD. Useful to usw with
+ * Create qemuFDPass pointing to an already passed FD. Useful to use with
* qemuFDPassTransferMonitorRollback, when restoring after restart.
*/
qemuFDPass *
--
2.39.0
1 year, 10 months
[PATCH 0/7] various cleanups
by Peter Krempa
Collection of cleanup patches from my previous series attempting to
remove secrets clearing refactored so that it doesn't depend on the
patches which were not accepted.
Peter Krempa (7):
virCryptoEncryptDataAESgnutls: Restructure control flow
virStorageBackendISCSISetAuth: Refactor cleanup
virStorageBackendISCSISetAuth: Use g_strndup to '\0' terminate data
virStorageBackendISCSIDirectSetAuth: Refactor cleanup
virStorageBackendISCSIDirectSetAuth: Use 'g_strndup' to '\0' terminate
data
libxlMakeNetworkDiskSrc: Refactor cleanup
storageBackendCreateQemuImgSecretPath: Refactor cleanup
src/libxl/libxl_conf.c | 17 ++++------
src/storage/storage_backend_iscsi.c | 17 ++++------
src/storage/storage_backend_iscsi_direct.c | 23 ++++++--------
src/storage/storage_util.c | 36 ++++++++++------------
src/util/vircrypto.c | 28 ++++++++---------
5 files changed, 49 insertions(+), 72 deletions(-)
--
2.39.1
1 year, 10 months