]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Generate command line for tb-cache feature
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Nov 2021 10:43:52 +0000 (11:43 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 13 Dec 2021 16:10:03 +0000 (17:10 +0100)
Generating command line is pretty easy - just put tb-size=XXX
onto -accel tcg part. Note, that QEMU expects the size in MiB.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/229
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.x86_64-latest.args [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 0017cf6ca7afa3af2dd20613519dca6a1bfc142f..ce223727490e478bfcefa552ff5acb96214d182f 100644 (file)
@@ -7200,6 +7200,12 @@ qemuBuildAccelCommandLine(virCommand *cmd,
     switch ((virDomainVirtType)def->virtType) {
     case VIR_DOMAIN_VIRT_QEMU:
         virBufferAddLit(&buf, "tcg");
+
+        if (def->features[VIR_DOMAIN_FEATURE_TCG] == VIR_TRISTATE_SWITCH_ON &&
+            def->tcg_features->tb_cache > 0) {
+            virBufferAsprintf(&buf, ",tb-size=%llu",
+                              def->tcg_features->tb_cache >> 10);
+        }
         break;
 
     case VIR_DOMAIN_VIRT_KVM:
diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.x86_64-latest.args b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.x86_64-latest.args
new file mode 100644 (file)
index 0000000..c9c71cf
--- /dev/null
@@ -0,0 +1,36 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-guest \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-guest/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-guest/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=guest,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-guest/master-key.aes"}' \
+-machine pc-q35-6.2,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-accel tcg,tb-size=100 \
+-cpu qemu64 \
+-m 4096 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":4294967296}' \
+-overcommit mem-lock=off \
+-smp 4,sockets=4,cores=1,threads=1 \
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device '{"driver":"pcie-root-port","port":8,"chassis":1,"id":"pci.1","bus":"pcie.0","multifunction":true,"addr":"0x1"}' \
+-device '{"driver":"pcie-root-port","port":9,"chassis":2,"id":"pci.2","bus":"pcie.0","addr":"0x1.0x1"}' \
+-device '{"driver":"pcie-root-port","port":10,"chassis":3,"id":"pci.3","bus":"pcie.0","addr":"0x1.0x2"}' \
+-device '{"driver":"qemu-xhci","id":"usb","bus":"pci.1","addr":"0x0"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.2","addr":"0x0"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
index 615f45376c0c32e60f010e0ca89572258dc9fb5e..0fe3fa9f76989392a7eab003cd9c5bc998895447 100644 (file)
@@ -3486,6 +3486,7 @@ mymain(void)
     DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-pc-4.2", "x86_64");
     DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-q35-4.2", "x86_64");
     DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-q35-4.2", "x86_64");
+    DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-features", "x86_64");
 
     DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
     DO_TEST_CAPS_LATEST("virtio-9p-createmode");