[PATCH v1] qemu: monitor: substitute missing model name for host-passthrough
by Collin Walling
When executing the hypervisor-cpu-compare/baseline commands and
the XML file contains a CPU definition using host-passthrough
and no model name, the commands will fail and return an error
message from the QMP response.
Let's fix this by checking for host-passthrough and a missing
model name when converting a CPU definition to a JSON object.
If these conditions are matched, then the JSON object will be
constructed using "host" as the model name.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1850680
Signed-off-by: Collin Walling <walling(a)linux.ibm.com>
---
src/qemu/qemu_monitor_json.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 3070c1e6b3..448a3a9356 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5804,9 +5804,20 @@ qemuMonitorJSONMakeCPUModel(virCPUDefPtr cpu,
{
virJSONValuePtr model = virJSONValueNewObject();
virJSONValuePtr props = NULL;
+ const char *model_name = cpu->model;
size_t i;
- if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0)
+ if (!model_name) {
+ if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
+ model_name = "host";
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cpu parameter is missing a model name"));
+ goto error;
+ }
+ }
+
+ if (virJSONValueObjectAppendString(model, "name", model_name) < 0)
goto error;
if (cpu->nfeatures || !migratable) {
--
2.26.2
4 years, 3 months
[PATCH] xen: Don't add dom0 twice on driver reload
by Jim Fehlig
When the xen driver loads, it probes libxl for some info about dom0 and
adds it to the virDomainObjList. The driver then looks for any domains
in stateDir and if they are still alive adds them to the list as well.
This logic is a bit flawed wrt handling driver reload and causes the
following error
internal error: unexpected domain Domain-0 already exists
A simple fix is to load all domains from stateDir first and then only
add dom0 if needed.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_driver.c | 46 +++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 161a6882f3..083738871d 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -604,27 +604,33 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
goto cleanup;
}
- if (!(def = virDomainDefNew()))
- goto cleanup;
+ /*
+ * On a driver reload dom0 will already exist. On host restart it must
+ * created.
+ */
+ if ((vm = virDomainObjListFindByID(driver->domains, 0)) == NULL) {
+ if (!(def = virDomainDefNew()))
+ goto cleanup;
- def->id = 0;
- def->virtType = VIR_DOMAIN_VIRT_XEN;
- def->name = g_strdup("Domain-0");
+ def->id = 0;
+ def->virtType = VIR_DOMAIN_VIRT_XEN;
+ def->name = g_strdup("Domain-0");
- def->os.type = VIR_DOMAIN_OSTYPE_XEN;
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
- if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) < 0)
- goto cleanup;
+ if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) < 0)
+ goto cleanup;
- if (!(vm = virDomainObjListAdd(driver->domains, def,
- driver->xmlopt,
- 0,
- NULL)))
- goto cleanup;
- def = NULL;
+ if (!(vm = virDomainObjListAdd(driver->domains, def,
+ driver->xmlopt,
+ 0,
+ NULL)))
+ goto cleanup;
+
+ vm->persistent = 1;
+ virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
+ }
- vm->persistent = 1;
- virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1, driver->xmlopt))
goto cleanup;
@@ -783,10 +789,6 @@ libxlStateInitialize(bool privileged,
if (!(libxl_driver->xmlopt = libxlCreateXMLConf(libxl_driver)))
goto error;
- /* Add Domain-0 */
- if (libxlAddDom0(libxl_driver) < 0)
- goto error;
-
/* Load running domains first. */
if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
cfg->stateDir,
@@ -796,6 +798,10 @@ libxlStateInitialize(bool privileged,
NULL, NULL) < 0)
goto error;
+ /* Add Domain-0 */
+ if (libxlAddDom0(libxl_driver) < 0)
+ goto error;
+
libxlReconnectDomains(libxl_driver);
/* Then inactive persistent configs */
--
2.28.0
4 years, 3 months
[PATCH 00/13] virStorageSourceNew failure handling and virDomainSnapshotAlignDisks refactors
by Peter Krempa
A set of patches that prevent failures from virStorageSourceNew and
refactor virDomainSnapshotAlignDisks for better readability.
Peter Krempa (13):
virStorageSourceNew: Abort on failure
virStorageVolDefParseXML: Use g_steal_pointer
qemuDomainBlockRebase: Replace ternary operator with if/else
qemuSnapshotCreateInactiveExternal: Don't access 'idx' of snapshot
virDomainSnapshotAlignDisks: Refactor cleanup
virDomainSnapshotAlignDisks: Rename 'def' -> 'snapdef'
virDomainSnapshotAlignDisks: Rename 'disk' -> 'snapdisk'
virDomainSnapshotAlignDisks: Add 'domdef' local variable
virDomainSnapshotAlignDisks: Extract domain disk definition to a local
variable
virDomainSnapshotAlignDisks: remove unnecessary 'tmp' variable
virDomainSnapshotAlignDisks: clarify handing of snapshot location
virDomainSnapshotAlignDisks: refactor extension to all disks
virDomainSnapshotDiskDef: Remove 'idx' field
src/conf/backup_conf.c | 7 +-
src/conf/domain_conf.c | 21 ++--
src/conf/snapshot_conf.c | 160 +++++++++++---------------
src/conf/snapshot_conf.h | 1 -
src/conf/storage_conf.c | 8 +-
src/qemu/qemu_domain.c | 21 ++--
src/qemu/qemu_driver.c | 18 ++-
src/qemu/qemu_migration.c | 7 +-
src/qemu/qemu_snapshot.c | 7 +-
src/storage/storage_backend_gluster.c | 5 +-
src/storage/storage_backend_logical.c | 4 +-
src/storage/storage_util.c | 10 +-
src/util/virstoragefile.c | 32 ++----
tests/qemublocktest.c | 16 +--
tests/virstoragetest.c | 5 +-
15 files changed, 121 insertions(+), 201 deletions(-)
--
2.26.2
4 years, 3 months
[libvirt PATCHv3] tests: build SELinux tests (glib chronicles?)
by Ján Tomko
We set WITH_LIBATTR in meson.build, not WITH_ATTR.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Fixes: 3ace72965c3b11fc763f781ae7ce3ca29dd36507
---
tests/meson.build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/meson.build b/tests/meson.build
index 31e8d66c7a..cb720f3afe 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -477,7 +477,7 @@ if conf.has('WITH_REMOTE')
endif
if conf.has('WITH_SECDRIVER_SELINUX')
- if conf.has('WITH_ATTR')
+ if conf.has('WITH_LIBATTR')
tests += [
{ 'name': 'securityselinuxtest' },
{ 'name': 'viridentitytest' },
@@ -485,7 +485,7 @@ if conf.has('WITH_SECDRIVER_SELINUX')
if conf.has('WITH_QEMU')
tests += [
- { 'name': 'securityselinuxlabeltest', 'link_whole': [ test_utils_qemu_lib ] },
+ { 'name': 'securityselinuxlabeltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] },
]
endif
endif
--
2.26.2
4 years, 3 months
[libvirt PATCH] util: do not unref event thread after joining it
by Ján Tomko
==295055== Invalid read of size 4
==295055== at 0x4DA4AE4: g_thread_unref (in /usr/lib64/libglib-2.0.so.0.6400.5)
==295055== by 0x491D5FA: vir_event_thread_finalize (vireventthread.c:47)
==295055== by 0x4E6BCFF: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.6400.5)
==295055== by 0x22F35CF4: qemuProcessQMPFree (qemu_process.c:8525)
==295055== by 0x22E71B58: glib_autoptr_clear_qemuProcessQMP (qemu_process.h:237)
...
==295055== by 0x22E98A29: qemuDomainPostParseDataAlloc (qemu_domain.c:5476)
==295055== by 0x49ABF83: virDomainDefPostParse (domain_conf.c:6023)
==295055== Address 0x2acb1c68 is 24 bytes inside a block of size 88 free'd
==295055== at 0x483B9F5: free (vg_replace_malloc.c:538)
==295055== by 0x4D80A4C: g_free (in /usr/lib64/libglib-2.0.so.0.6400.5)
...
==295055== by 0x491D5F1: vir_event_thread_finalize (vireventthread.c:46)
==295055== by 0x4E6BCFF: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.6400.5)
==295055== by 0x22F35CF4: qemuProcessQMPFree (qemu_process.c:8525)
==295055== by 0x22E71B58: glib_autoptr_clear_qemuProcessQMP (qemu_process.h:237)
...
==295055== Block was alloc'd at
==295055== at 0x483A809: malloc (vg_replace_malloc.c:307)
==295055== by 0x4D80958: g_malloc (in /usr/lib64/libglib-2.0.so.0.6400.5)
...
==295055== by 0x4DA4C32: g_thread_try_new (in /usr/lib64/libglib-2.0.so.0.6400.5)
==295055== by 0x491D3BC: virEventThreadStart (vireventthread.c:159)
==295055== by 0x491D3BC: virEventThreadNew (vireventthread.c:185)
...
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Fixes: f4fc3db9204407874181117085756c9ced78adad
---
src/util/vireventthread.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/util/vireventthread.c b/src/util/vireventthread.c
index 1bca2aa57a..8342f420f6 100644
--- a/src/util/vireventthread.c
+++ b/src/util/vireventthread.c
@@ -44,7 +44,6 @@ vir_event_thread_finalize(GObject *object)
if (evt->thread) {
g_main_loop_quit(evt->loop);
g_thread_join(evt->thread);
- g_thread_unref(evt->thread);
}
g_main_loop_unref(evt->loop);
--
2.26.2
4 years, 3 months
[libvirt PATCH] virnetdaemon: fix memory leak in virNetDaemonCallInhibit
by Pavel Hrdina
g_variant_new() returns a weak reference which can be consumed by passing
to other g_variant* functions or to g_dbus_connection_call* functions.
This make it possible to call g_variant_new() directly as argument to
the functions above. Because this might be confusing I explicitly call
g_variant_ref_sink() to make it normal reference in both
virGDBusCallMethod() and virGDBusCallMethodWithFD() so the caller is
always responsible for the data.
Reported-by: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/rpc/virnetdaemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index f3a5e9f75c..2e01244f74 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -469,7 +469,7 @@ virNetDaemonCallInhibit(virNetDaemonPtr dmn,
{
g_autoptr(GVariant) reply = NULL;
g_autoptr(GUnixFDList) replyFD = NULL;
- GVariant *message = NULL;
+ g_autoptr(GVariant) message = NULL;
GDBusConnection *systemBus;
int fd;
int rc;
--
2.26.2
4 years, 3 months
[libvirt PATCH] util/virgdbus: fix memory leak in virGDBusIsServiceInList
by Pavel Hrdina
g_variant_iter_loop() handles freeing all arguments unless we break out
of the loop, in that case we have to free them manually.
Reported-by: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/virgdbus.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virgdbus.c b/src/util/virgdbus.c
index cd9ca8d5d6..4360a6acff 100644
--- a/src/util/virgdbus.c
+++ b/src/util/virgdbus.c
@@ -359,8 +359,10 @@ virGDBusIsServiceInList(const char *listMethod,
g_variant_get(reply, "(as)", &iter);
while (g_variant_iter_loop(iter, "s", &str)) {
- if (STREQ(str, name))
+ if (STREQ(str, name)) {
+ g_free(str);
return 0;
+ }
}
return -2;
--
2.26.2
4 years, 3 months
[libvirt PATCHv2 0/2] tests: switch to g_new0 (glib chronicles)
by Ján Tomko
This time actually compile-tested.
Ján Tomko (2):
tests: build SELinux tests
tests: use g_new0 instead of VIR_ALLOC_N
tests/commandtest.c | 7 +++----
tests/domaincapstest.c | 3 +--
tests/fdstreamtest.c | 10 ++++------
tests/meson.build | 2 +-
tests/qemuxml2argvtest.c | 3 +--
tests/securityselinuxlabeltest.c | 3 +--
tests/securityselinuxtest.c | 3 +--
tests/testutils.c | 8 ++------
tests/testutilsqemu.c | 6 ++----
tests/vircgrouptest.c | 3 +--
tests/vircryptotest.c | 5 ++---
tests/virhostcputest.c | 3 +--
tests/virnetmessagetest.c | 6 ++----
tests/virnetsockettest.c | 6 +-----
tests/virnettlshelpers.c | 3 +--
tests/virstringtest.c | 3 +--
tests/xlconfigtest.c | 3 +--
tests/xmconfigtest.c | 3 +--
18 files changed, 27 insertions(+), 53 deletions(-)
--
2.26.2
4 years, 3 months
[PATCH v2 0/2] block: deprecate the sheepdog driver
by Daniel P. Berrangé
2 years back I proposed dropping the sheepdog mailing list from the
MAINTAINERS file, but somehow the patch never got picked up:
https://lists.gnu.org/archive/html/qemu-block/2018-03/msg01048.html
So here I am with the same patch again.
This time I go further and deprecate the sheepdog driver entirely.
See the rationale in the second patch commit message.
Daniel P. Berrangé (2):
block: drop moderated sheepdog mailing list from MAINTAINERS file
block: deprecate the sheepdog block driver
MAINTAINERS | 1 -
block/sheepdog.c | 15 +++++++++++++++
configure | 5 +++--
docs/system/deprecated.rst | 9 +++++++++
4 files changed, 27 insertions(+), 3 deletions(-)
--
2.26.2
4 years, 3 months
[PATCH] docs: manpages: Strip table of contents from manpages
by Peter Krempa
After meson conversion the man pages started to contain the table of
contents.
In autoconf we prevented this by a 'grep -v ::contents' in the command
building the manpages.
A more cultured solution is to strip out the 'contents' docutils element
directly.
Reported-by: Daniel P. Berrangé <berrange(a)redhat.com>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
docs/manpages/meson.build | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build
index 3888bb8efe..7ed1d304a4 100644
--- a/docs/manpages/meson.build
+++ b/docs/manpages/meson.build
@@ -89,7 +89,8 @@ foreach data : docs_man_files
man_file,
input: rst_file,
output: man_file,
- command: [ rst2man_prog, '--strict', '@INPUT@', '@OUTPUT@' ],
+ # 'contents' element is the table of contents which is undesired in manpage
+ command: [ rst2man_prog, '--strip-elements-with-class', 'contents', '--strict', '@INPUT@', '@OUTPUT@' ],
install: true,
install_dir: mandir / 'man@0@'.format(data['section']),
)
--
2.26.2
4 years, 3 months