[PATCH] virQEMUDriverGetDomainCapabilities: Validate machine type
by Michal Privoznik
When calling virConnectGetDomainCapabilities() (exposed as virsh
domcapabilities) users have option to specify whatever sub-set of
{ emulatorbin, arch, machine, virttype } they want. Then we have
a logic (hidden in virQEMUCapsCacheLookupDefault()) that picks
qemuCaps that satisfy values passed by user. And whatever was not
specified is then set to the default value as specified by picked
qemuCaps. For instance: if no machine type was provided but
emulatorbin was, then the machine type is set to the default one
as defined by the emulatorbin.
Or, when just virttype was set then the remaining three values
are set to their respective defaults. Except, we have a crasher
in this case:
# virsh domcapabilities --virttype hvf
error: Disconnected from qemu:///system due to end of file
error: failed to get emulator capabilities
error: End of file while reading data: Input/output error
This is because for 'hvf' virttype (at least my) QEMU does not
have any machine type. Therefore, @machine is set to NULL and the
rest of the code does not expect that.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_conf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ae5bbcd138..cbd339f594 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1454,6 +1454,13 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *driver,
g_autoptr(virDomainCaps) domCaps = NULL;
const char *path = virQEMUCapsGetBinary(qemuCaps);
+ if (!virQEMUCapsIsMachineSupported(qemuCaps, virttype, machine)) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("the machine '%s' is not supported by emulator '%s'"),
+ NULLSTR(machine), path);
+ return NULL;
+ }
+
if (!(domCaps = virDomainCapsNew(path, machine, arch, virttype)))
return NULL;
--
2.38.2
2 years
[PATCH v2] MIPS: remove support for trap and emulate KVM
by Philippe Mathieu-Daudé
From: Paolo Bonzini <pbonzini(a)redhat.com>
This support was limited to the Malta board, drop it.
I do not have a machine that can run VZ KVM, so I am assuming
that it works for -M malta as well.
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd(a)linaro.org>
---
Since Paolo's v1:
- Remove cpu_mips_kvm_um_phys_to_kseg0() declaration in "cpu.h"
- Remove unused KVM_KSEG0_BASE/KVM_KSEG2_BASE definitions
- Use USEG_LIMIT/KSEG0_BASE instead of magic values
/* Check where the kernel has been linked */
- if (!(kernel_entry & 0x80000000ll)) {
- error_report("CONFIG_KVM_GUEST kernels are not supported");
+ if (kernel_entry <= USEG_LIMIT) {
+ error_report("Trap-and-Emul kernels (Linux CONFIG_KVM_GUEST)"
+ " are not supported");
- env->CP0_EBase = (cs->cpu_index & 0x3FF) | (int32_t)0x80000000;
+ env->CP0_EBase = KSEG0_BASE | (cs->cpu_index & 0x3FF);
---
docs/about/deprecated.rst | 9 -------
docs/about/removed-features.rst | 9 +++++++
hw/mips/malta.c | 46 +++++----------------------------
target/mips/cpu.c | 7 +----
target/mips/cpu.h | 3 ---
target/mips/internal.h | 3 ---
target/mips/kvm.c | 11 +-------
target/mips/sysemu/addr.c | 17 ------------
target/mips/sysemu/physaddr.c | 13 ----------
9 files changed, 18 insertions(+), 100 deletions(-)
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 93affe3669..b28f50b22f 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -199,15 +199,6 @@ deprecated. Use ``sections`` instead.
Member ``section-size`` in return value elements with meta-type ``uint64`` is
deprecated. Use ``sections`` instead.
-System accelerators
--------------------
-
-MIPS ``Trap-and-Emul`` KVM support (since 6.0)
-''''''''''''''''''''''''''''''''''''''''''''''
-
-The MIPS ``Trap-and-Emul`` KVM host and guest support has been removed
-from Linux upstream kernel, declare it deprecated.
-
Host Architectures
------------------
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index 63df9848fd..22b4b5d128 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -617,6 +617,15 @@ x86 ``Icelake-Client`` CPU (removed in 7.1)
There isn't ever Icelake Client CPU, it is some wrong and imaginary one.
Use ``Icelake-Server`` instead.
+System accelerators
+-------------------
+
+MIPS "Trap-and-Emulate" KVM support (removed in 8.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The MIPS "Trap-and-Emulate" KVM host and guest support was removed
+from Linux in 2021, and is not supported anymore by QEMU either.
+
System emulator machines
------------------------
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index e5050ecd3c..fed8b65f1e 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -58,6 +58,7 @@
#include "semihosting/semihost.h"
#include "hw/mips/cps.h"
#include "hw/qdev-clock.h"
+#include "target/mips/internal.h"
#define ENVP_PADDR 0x2000
#define ENVP_VADDR cpu_mips_phys_to_kseg0(NULL, ENVP_PADDR)
@@ -870,7 +871,6 @@ static uint64_t load_kernel(void)
uint32_t *prom_buf;
long prom_size;
int prom_index = 0;
- uint64_t (*xlate_to_kseg0) (void *opaque, uint64_t addr);
uint8_t rng_seed[32];
char rng_seed_hex[sizeof(rng_seed) * 2 + 1];
size_t rng_seed_prom_offset;
@@ -894,19 +894,10 @@ static uint64_t load_kernel(void)
}
/* Check where the kernel has been linked */
- if (kernel_entry & 0x80000000ll) {
- if (kvm_enabled()) {
- error_report("KVM guest kernels must be linked in useg. "
- "Did you forget to enable CONFIG_KVM_GUEST?");
- exit(1);
- }
-
- xlate_to_kseg0 = cpu_mips_phys_to_kseg0;
- } else {
- /* if kernel entry is in useg it is probably a KVM T&E kernel */
- mips_um_ksegs_enable();
-
- xlate_to_kseg0 = cpu_mips_kvm_um_phys_to_kseg0;
+ if (kernel_entry <= USEG_LIMIT) {
+ error_report("Trap-and-Emul kernels (Linux CONFIG_KVM_GUEST)"
+ " are not supported");
+ exit(1);
}
/* load initrd */
@@ -947,7 +938,7 @@ static uint64_t load_kernel(void)
if (initrd_size > 0) {
prom_set(prom_buf, prom_index++,
"rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s",
- xlate_to_kseg0(NULL, initrd_offset),
+ cpu_mips_phys_to_kseg0(NULL, initrd_offset),
initrd_size, loaderparams.kernel_cmdline);
} else {
prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline);
@@ -1039,11 +1030,6 @@ static void main_cpu_reset(void *opaque)
}
malta_mips_config(cpu);
-
- if (kvm_enabled()) {
- /* Start running from the bootloader we wrote to end of RAM */
- env->active_tc.PC = 0x40000000 + loaderparams.ram_low_size;
- }
}
static void create_cpu_without_cps(MachineState *ms, MaltaState *s,
@@ -1177,13 +1163,7 @@ void mips_malta_init(MachineState *machine)
fl_idx++;
if (kernel_filename) {
ram_low_size = MIN(ram_size, 256 * MiB);
- /* For KVM we reserve 1MB of RAM for running bootloader */
- if (kvm_enabled()) {
- ram_low_size -= 0x100000;
- bootloader_run_addr = cpu_mips_kvm_um_phys_to_kseg0(NULL, ram_low_size);
- } else {
- bootloader_run_addr = cpu_mips_phys_to_kseg0(NULL, RESET_ADDRESS);
- }
+ bootloader_run_addr = cpu_mips_phys_to_kseg0(NULL, RESET_ADDRESS);
/* Write a small bootloader to the flash location. */
loaderparams.ram_size = ram_size;
@@ -1200,20 +1180,8 @@ void mips_malta_init(MachineState *machine)
write_bootloader_nanomips(memory_region_get_ram_ptr(bios),
bootloader_run_addr, kernel_entry);
}
- if (kvm_enabled()) {
- /* Write the bootloader code @ the end of RAM, 1MB reserved */
- write_bootloader(memory_region_get_ram_ptr(ram_low_preio) +
- ram_low_size,
- bootloader_run_addr, kernel_entry);
- }
} else {
target_long bios_size = FLASH_SIZE;
- /* The flash region isn't executable from a KVM guest */
- if (kvm_enabled()) {
- error_report("KVM enabled but no -kernel argument was specified. "
- "Booting from flash is not supported with KVM.");
- exit(1);
- }
/* Load firmware from flash. */
if (!dinfo) {
/* Load a BIOS image. */
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 17bbcbf5ff..f8c8e0ba39 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -291,12 +291,7 @@ static void mips_cpu_reset_hold(Object *obj)
env->tlb->tlb_in_use = env->tlb->nb_tlb;
env->CP0_Wired = 0;
env->CP0_GlobalNumber = (cs->cpu_index & 0xFF) << CP0GN_VPId;
- env->CP0_EBase = (cs->cpu_index & 0x3FF);
- if (mips_um_ksegs_enabled()) {
- env->CP0_EBase |= 0x40000000;
- } else {
- env->CP0_EBase |= (int32_t)0x80000000;
- }
+ env->CP0_EBase = KSEG0_BASE | (cs->cpu_index & 0x3FF);
if (env->CP0_Config3 & (1 << CP0C3_CMGCR)) {
env->CP0_CMGCRBase = 0x1fbf8000 >> 4;
}
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 0a085643a3..caf2b06911 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1296,11 +1296,8 @@ void cpu_set_exception_base(int vp_index, target_ulong address);
uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr);
uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr);
-uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr);
uint64_t cpu_mips_kseg1_to_phys(void *opaque, uint64_t addr);
uint64_t cpu_mips_phys_to_kseg1(void *opaque, uint64_t addr);
-bool mips_um_ksegs_enabled(void);
-void mips_um_ksegs_enable(void);
#if !defined(CONFIG_USER_ONLY)
diff --git a/target/mips/internal.h b/target/mips/internal.h
index 57b312689a..4b0031d10d 100644
--- a/target/mips/internal.h
+++ b/target/mips/internal.h
@@ -99,9 +99,6 @@ int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
#define KSEG2_BASE ((target_ulong)(int32_t)0xC0000000UL)
#define KSEG3_BASE ((target_ulong)(int32_t)0xE0000000UL)
-#define KVM_KSEG0_BASE ((target_ulong)(int32_t)0x40000000UL)
-#define KVM_KSEG2_BASE ((target_ulong)(int32_t)0x60000000UL)
-
#if !defined(CONFIG_USER_ONLY)
enum {
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index bcb8e06b2c..c14e8f550f 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -1268,25 +1268,16 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
int mips_kvm_type(MachineState *machine, const char *vm_type)
{
-#if defined(KVM_CAP_MIPS_VZ) || defined(KVM_CAP_MIPS_TE)
+#if defined(KVM_CAP_MIPS_VZ)
int r;
KVMState *s = KVM_STATE(machine->accelerator);
-#endif
-#if defined(KVM_CAP_MIPS_VZ)
r = kvm_check_extension(s, KVM_CAP_MIPS_VZ);
if (r > 0) {
return KVM_VM_MIPS_VZ;
}
#endif
-#if defined(KVM_CAP_MIPS_TE)
- r = kvm_check_extension(s, KVM_CAP_MIPS_TE);
- if (r > 0) {
- return KVM_VM_MIPS_TE;
- }
-#endif
-
return -1;
}
diff --git a/target/mips/sysemu/addr.c b/target/mips/sysemu/addr.c
index 86f1c129c9..4f025be44a 100644
--- a/target/mips/sysemu/addr.c
+++ b/target/mips/sysemu/addr.c
@@ -23,8 +23,6 @@
#include "qemu/osdep.h"
#include "cpu.h"
-static int mips_um_ksegs;
-
uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr)
{
return addr & 0x1fffffffll;
@@ -35,11 +33,6 @@ uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr)
return addr | ~0x7fffffffll;
}
-uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr)
-{
- return addr | 0x40000000ll;
-}
-
uint64_t cpu_mips_kseg1_to_phys(void *opaque, uint64_t addr)
{
return addr & 0x1fffffffll;
@@ -49,13 +42,3 @@ uint64_t cpu_mips_phys_to_kseg1(void *opaque, uint64_t addr)
{
return (addr & 0x1fffffffll) | 0xffffffffa0000000ll;
}
-
-bool mips_um_ksegs_enabled(void)
-{
- return mips_um_ksegs;
-}
-
-void mips_um_ksegs_enable(void)
-{
- mips_um_ksegs = 1;
-}
diff --git a/target/mips/sysemu/physaddr.c b/target/mips/sysemu/physaddr.c
index 1918633aa1..2970df8a09 100644
--- a/target/mips/sysemu/physaddr.c
+++ b/target/mips/sysemu/physaddr.c
@@ -130,19 +130,6 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical,
/* effective address (modified for KVM T&E kernel segments) */
target_ulong address = real_address;
- if (mips_um_ksegs_enabled()) {
- /* KVM T&E adds guest kernel segments in useg */
- if (real_address >= KVM_KSEG0_BASE) {
- if (real_address < KVM_KSEG2_BASE) {
- /* kseg0 */
- address += KSEG0_BASE - KVM_KSEG0_BASE;
- } else if (real_address <= USEG_LIMIT) {
- /* kseg2/3 */
- address += KSEG2_BASE - KVM_KSEG2_BASE;
- }
- }
- }
-
if (address <= USEG_LIMIT) {
/* useg */
uint16_t segctl;
--
2.38.1
2 years
[PATCH v2 1/2] libxl: add validation if sound device is supported
by Marek Marczykowski-Górecki
Xen supports only subset of libvirt's sound devices, and starting with
Xen 4.17 it is enforced by libxl. Verify it early.
Signed-off-by: Marek Marczykowski-Górecki <marmarek(a)invisiblethingslab.com>
---
src/libxl/libxl_domain.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 2d53250895..6507e34469 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -312,6 +312,27 @@ libxlDomainDefValidate(const virDomainDef *def,
return -1;
}
+ if (def->nsounds > 0) {
+ virDomainSoundDef *snd = def->sounds[0];
+ switch (snd->model) {
+ case VIR_DOMAIN_SOUND_MODEL_ICH6:
+ case VIR_DOMAIN_SOUND_MODEL_ES1370:
+ case VIR_DOMAIN_SOUND_MODEL_AC97:
+ case VIR_DOMAIN_SOUND_MODEL_SB16:
+ break;
+ default:
+ case VIR_DOMAIN_SOUND_MODEL_PCSPK:
+ case VIR_DOMAIN_SOUND_MODEL_ICH7:
+ case VIR_DOMAIN_SOUND_MODEL_USB:
+ case VIR_DOMAIN_SOUND_MODEL_ICH9:
+ case VIR_DOMAIN_SOUND_MODEL_LAST:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported audio model %s"),
+ virDomainSoundModelTypeToString(snd->model));
+ return -1;
+ }
+ }
+
return 0;
}
--
2.37.3
2 years
[PATCH V3 00/11] spec: Decompose the daemon subpackage
by Jim Fehlig
This is V3 of
https://listman.redhat.com/archives/libvir-list/2022-December/236337.html
The end goal is to remove the libvirt-dameon dependency on the various
libvirt-daemon-driver-foo subpackages, allowing installation of a
modular daemon configuration without the traditional monolithic libvirtd.
Changes from V2:
* Move more files and dependencies to the libvirt-daemon-common package
* Address many more review comments
Jim Fehlig (11):
spec: Move virtlockd to a new subpackage libvirt-daemon-lock
spec: Move virtlogd to a new subpackage libvirt-daemon-log
spec: Move virtproxyd to a new subpackage libvirt-daemon-proxy
spec: Move lockd plugin to a new subpackage
spec: Rename the libvirt-lock-sanlock subpackage
spec: Move common files and dependencies to libvirt-daemon-common
spec: Add module-init-tools dependency to nodedev and lxc drivers
spec: Add numad dependency to qemu and lxc drivers
spec: Remove libvirt-daemon dependency from drivers
spec: Remove libvirt-daemon dependency from hypervisor subpackages
kbase: Update rpm-deployment.rst with new subpackages
docs/kbase/rpm-deployment.rst | 50 ++++--
libvirt.spec.in | 329 ++++++++++++++++++++++++----------
2 files changed, 267 insertions(+), 112 deletions(-)
--
2.38.1
2 years
[PATCH] libxl: adjust 'ich6' sound card name
by Marek Marczykowski-Górecki
Xen 4.17 has strict parsing of 'soundhw' option that allows only
specific values (instead of passing through any value directly to
qemu's -soundhw option, it uses -device now). For 'intel-hda' audio
device, it requires "hda" string. "hda" works with older libxl too.
Other supported models are the same as in libvirt XML.
Signed-off-by: Marek Marczykowski-Górecki <marmarek(a)invisiblethingslab.com>
---
src/libxl/libxl_conf.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index d13e48abb2..b84257bc12 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -593,7 +593,26 @@ libxlMakeDomBuildInfo(virDomainDef *def,
*/
virDomainSoundDef *snd = def->sounds[0];
- b_info->u.hvm.soundhw = g_strdup(virDomainSoundModelTypeToString(snd->model));
+ switch (snd->model) {
+ case VIR_DOMAIN_SOUND_MODEL_ICH6:
+ b_info->u.hvm.soundhw = g_strdup("hda");
+ break;
+ case VIR_DOMAIN_SOUND_MODEL_ES1370:
+ case VIR_DOMAIN_SOUND_MODEL_AC97:
+ case VIR_DOMAIN_SOUND_MODEL_SB16:
+ b_info->u.hvm.soundhw = g_strdup(virDomainSoundModelTypeToString(snd->model));
+ break;
+ default:
+ case VIR_DOMAIN_SOUND_MODEL_PCSPK:
+ case VIR_DOMAIN_SOUND_MODEL_ICH7:
+ case VIR_DOMAIN_SOUND_MODEL_USB:
+ case VIR_DOMAIN_SOUND_MODEL_ICH9:
+ case VIR_DOMAIN_SOUND_MODEL_LAST:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported audio model %s"),
+ virDomainSoundModelTypeToString(snd->model));
+ return -1;
+ }
}
for (i = 0; i < def->os.nBootDevs; i++) {
--
2.37.3
2 years
[PATCH 0/2] util: qemu: Perform the 'skipKey' handling only on the top level object
by Peter Krempa
Semantically we need to handle one of the keys in the top level object
spearately, thus skipping it in nested objects doesn't make sense.
Peter Krempa (2):
virqemu: Don't strip the requested key from nested objects
util: qemu: Remove 'skipKey' argument from
virQEMUBuildCommandLineJSONArrayFormatFunc prototype
src/util/virqemu.c | 21 +++++++++------------
src/util/virqemu.h | 12 ++++--------
2 files changed, 13 insertions(+), 20 deletions(-)
--
2.38.1
2 years
[RFC PATCH 0/1] secret: Inhibit shutdown for ephemeral secrets
by Michal Privoznik
I'm kind of convinced that we want to do this, but also it's a
significant change in the behaviour of the daemon, hence RFC prefix.
This stemmed from a discussion with a user who wants us to use something
more secure than base64 encoded secret values stored on a disk. They
suggested storing the values in TPM and while that might sound like a
good idea, I suggested using ephemeral secrets for the time being. Well,
because of '--timeout 120', ephemeral secrets are short lived, indeed.
Meanwhile, let me see if there's a library we could use to talk to TPM.
Michal Prívozník (1):
secret: Inhibit shutdown for ephemeral secrets
src/secret/secret_driver.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
--
2.38.2
2 years
[PATCH V2 0/9] spec: Decompose the daemon subpackage
by Jim Fehlig
This is a V2 of:
https://listman.redhat.com/archives/libvir-list/2022-December/236073.html
Original RFC:
https://listman.redhat.com/archives/libvir-list/2022-November/235924.html
The end goal is to remove the libvirt-dameon dependency on the various
libvirt-daemon-driver-foo subpackages, allowing installation of a
modular daemon configuration without the traditional monolithic libvirtd.
Change from V1:
- Change name of new subpackage libvirt-daemon-client to libvirt-daemon-common
- Rename the libvirt-lock-sanlock package to libvirt-daemon-plugin-sanlock
- Update rpm-deployment kbase article
- Misc review comments addressed
Jim Fehlig (9):
spec: Move virtlockd to a new subpackage libvirt-daemon-lock
spec: Move virtlogd to a new subpackage libvirt-daemon-log
spec: Move virtproxyd to a new subpackage libvirt-daemon-proxy
spec: Move lockd plugin to a new subpackage
spec: Rename the libvirt-lock-sanlock subpackage
spec: Move common files to a new subpackage libvirt-daemon-common
spec: Remove libvirt-daemon dependency from drivers
spec: Remove libvirt-daemon dependency from hypervisor subpackages
kbase: Update rpm-deployment.rst with new subpackages
docs/kbase/rpm-deployment.rst | 38 ++++-
libvirt.spec.in | 294 +++++++++++++++++++++++-----------
2 files changed, 235 insertions(+), 97 deletions(-)
--
2.38.1
2 years
Setting SELinux label on TPM state during migration
by Michal Prívozník
Stefan,
as you saw, I'm trying to implement support for migration with TPM state
on a shared volume. I mean, it is working when the shared volume is an
NFS mount point because NFS does not really propagate SELinux labels,
but rather has this 'virt_use_nfs' sebool which effectivelly allows all
svirt_t processes to access NFS (thus including swtpm). But things get
trickier when a distributed FS that knows SELinux properly (e.g. ceph)
is used instead.
What I am currently struggling with is - finding the sweet spot when the
source swtpm has let go of the state and the destination has not
accessed it (because if it did it would get EPERM).
Bottom line - the SELinux label is generated dynamically on each guest
startup (to ensure its uniqueness on the system). Therefore, the label
on the destination is different to the one on the source.
The behavior I'm seeing now is:
1) the source starts migration:
{"execute":"migrate","arguments":{"detach":true,"resume":false,"uri":"fd:migrate"},"id":"libvirt-428"}
2) the destination does not touch the swtpm state right away, but when
the TPM state comes in the migration stream, it is touched. Partial logs
from the destination:
->
{"execute":"migrate-incoming","arguments":{"uri":"tcp:[::]:49152"},"id":"libvirt-415"}
<- {"timestamp": {"seconds": 1671449778, "microseconds": 500164},
"event": "MIGRATION", "data": {"status": "setup"}}]
<- {"return": {}, "id": "libvirt-415"}
<- {"timestamp": {"seconds": 1671449778, "microseconds": 732358},
"event": "MIGRATION", "data": {"status": "active"}}
Now, before QEMU sends MIGRATION status:completed, I can see QEMU
accessing the TPM state:
Thread 1 "qemu-kvm" hit Breakpoint 1, tpm_emulator_set_state_blob
(tpm_emu=0x5572af389cb0, type=1, tsb=0x5572af389db0, flags=0) at
../backends/tpm/tpm_emulator.c:796
796 {
(gdb) bt
#0 tpm_emulator_set_state_blob (tpm_emu=0x5572af389cb0, type=1,
tsb=0x5572af389db0, flags=0) at ../backends/tpm/tpm_emulator.c:796
#1 0x00005572acf21fe5 in tpm_emulator_post_load (opaque=0x5572af389cb0,
version_id=<optimized out>) at ../backends/tpm/tpm_emulator.c:868
#2 0x00005572acf25497 in vmstate_load_state (f=0x5572af512a10,
vmsd=0x5572ad7743b8 <vmstate_tpm_emulator>, opaque=0x5572af389cb0,
version_id=1) at ../migration/vmstate.c:162
#3 0x00005572acf45753 in qemu_loadvm_state_main (f=0x5572af512a10,
mis=0x5572af39b4e0) at ../migration/savevm.c:876
#4 0x00005572acf47591 in qemu_loadvm_state (f=0x5572af512a10) at
../migration/savevm.c:2712
#5 0x00005572acf301f6 in process_incoming_migration_co
(opaque=<optimized out>) at ../migration/migration.c:591
#6 0x00005572ad400976 in coroutine_trampoline (i0=<optimized out>,
i1=<optimized out>) at ../util/coroutine-ucontext.c:177
#7 0x00007f64ca22a360 in ?? () from target:/lib64/libc.so.6
#8 0x00007f64c948cbc0 in ?? ()
#9 0x0000000000000000 in ?? ()
This in turn means that swtpm on the destination is going to CMD_INIT
itself while the source is still using it.
I wonder what we can do about this. Perhaps - postpone init until the
time the vCPUs on the destination are resumed? That way libvirt on the
source could restore labels (effectively cut the source swtpm process
off the TPM state), then libvirtd on the destination could set the label
and 'cont'. If 'cont' fails for whatever reason then the source libvirtd
would just set the label on the TPM state and everything is back to normal.
Corresponding BZ link: https://bugzilla.redhat.com/show_bug.cgi?id=2130192
Michal
2 years
Libvirt support for qemu reconnect flag
by Miguel Ping
Hello,
Qemu has support for reconnect-delay parameter, that allows for the
qemu nbd client to retry failed NBD operations. This is useful if you
are running a custom NBD server and want to update the server without
failing requests.
Unfortunately, the only way to supply these flags is at domain
creation via qemu commandline passthrough feature [1]; there is no way
to supply them when eg hotpluggin a disk via eg: "virsh attach-device
..."
Is there interest in libvirt for a patch that supports qemu "reconnect
delay" param?
What would be the best way to move forward with such a patch? I think
the param can be supported in either the device definition (eg: the
<reconnect enabled='yes' timeout='10'/> option already exists for disk
type="vhostuser"), or globally via the qemu.conf configuration file.
Thank you for your time
[1] https://libvirt.org/kbase/qemu-passthrough-security.html#xml-document-add...
2 years