mirror of
				https://gitlab.com/libvirt/libvirt.git
				synced 2025-10-30 20:24:58 +03:00 
			
		
		
		
	We already have virAsprintf, so picking a similar name helps for seeing a similar purpose. Furthermore, the prefix V before printf generally implies 'va_list', even though this variant was '...', and the old name got in the way of adding a new va_list version. global rename performed with: $ git grep -l virBufferVSprintf \ | xargs -L1 sed -i 's/virBufferVSprintf/virBufferAsprintf/g' then revert the changes in ChangeLog-old.
		
			
				
	
	
		
			123 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			123 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From d67c189e80e6aef7adf13e5763365555cfc1a02a Mon Sep 17 00:00:00 2001
 | |
| From: Eric Blake <eblake@redhat.com>
 | |
| Date: Wed, 29 Sep 2010 15:58:47 -0600
 | |
| Subject: [PATCH 10/15] vcpu: improve vcpu support in qemu command line
 | |
| 
 | |
| * src/qemu/qemu_conf.c (qemuParseCommandLineSmp): Distinguish
 | |
| between vcpus and maxvcpus, for new enough qemu.
 | |
| * tests/qemuargv2xmltest.c (mymain): Add new test.
 | |
| * tests/qemuxml2argvtest.c (mymain): Likewise.
 | |
| * tests/qemuxml2xmltest.c (mymain): Likewise.
 | |
| * tests/qemuxml2argvdata/qemuxml2argv-smp.args: New file.
 | |
| ---
 | |
|  src/qemu/qemu_conf.c                         |   13 +++++++++----
 | |
|  tests/qemuargv2xmltest.c                     |    2 ++
 | |
|  tests/qemuxml2argvdata/qemuxml2argv-smp.args |    1 +
 | |
|  tests/qemuxml2argvtest.c                     |    2 ++
 | |
|  tests/qemuxml2xmltest.c                      |    2 ++
 | |
|  5 files changed, 16 insertions(+), 4 deletions(-)
 | |
|  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smp.args
 | |
| 
 | |
| diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 | |
| index 38c8351..ffe184b 100644
 | |
| --- a/src/qemu/qemu_conf.c
 | |
| +++ b/src/qemu/qemu_conf.c
 | |
| @@ -3714,6 +3714,8 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
 | |
|      virBufferAsprintf(&buf, "%u", def->vcpus);
 | |
| 
 | |
|      if ((qemuCmdFlags & QEMUD_CMD_FLAG_SMP_TOPOLOGY)) {
 | |
| +        if (def->vcpus != def->maxvcpus)
 | |
| +            virBufferAsprintf(&buf, ",maxcpus=%u", def->maxvcpus);
 | |
|          /* sockets, cores, and threads are either all zero
 | |
|           * or all non-zero, thus checking one of them is enough */
 | |
|          if (def->cpu && def->cpu->sockets) {
 | |
| @@ -3726,12 +3728,12 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
 | |
|              virBufferAsprintf(&buf, ",cores=%u", 1);
 | |
|              virBufferAsprintf(&buf, ",threads=%u", 1);
 | |
|          }
 | |
| -    }
 | |
| -    if (def->vcpus != def->maxvcpus) {
 | |
| +    } else if (def->vcpus != def->maxvcpus) {
 | |
|          virBufferFreeAndReset(&buf);
 | |
| +        /* FIXME - consider hot-unplugging cpus after boot for older qemu */
 | |
|          qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
 | |
|                          _("setting current vcpu count less than maximum is "
 | |
| -                          "not supported yet"));
 | |
| +                          "not supported with this QEMU binary"));
 | |
|          return NULL;
 | |
|      }
 | |
| 
 | |
| @@ -6153,6 +6155,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
 | |
|      unsigned int sockets = 0;
 | |
|      unsigned int cores = 0;
 | |
|      unsigned int threads = 0;
 | |
| +    unsigned int maxcpus = 0;
 | |
|      int i;
 | |
|      int nkws;
 | |
|      char **kws;
 | |
| @@ -6180,12 +6183,14 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
 | |
|                  cores = n;
 | |
|              else if (STREQ(kws[i], "threads"))
 | |
|                  threads = n;
 | |
| +            else if (STREQ(kws[i], "maxcpus"))
 | |
| +                maxcpus = n;
 | |
|              else
 | |
|                  goto syntax;
 | |
|          }
 | |
|      }
 | |
| 
 | |
| -    dom->maxvcpus = dom->vcpus;
 | |
| +    dom->maxvcpus = maxcpus ? maxcpus : dom->vcpus;
 | |
| 
 | |
|      if (sockets && cores && threads) {
 | |
|          virCPUDefPtr cpu;
 | |
| diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
 | |
| index 4f9ec84..d941b0b 100644
 | |
| --- a/tests/qemuargv2xmltest.c
 | |
| +++ b/tests/qemuargv2xmltest.c
 | |
| @@ -221,6 +221,8 @@ mymain(int argc, char **argv)
 | |
| 
 | |
|      DO_TEST("hostdev-pci-address");
 | |
| 
 | |
| +    DO_TEST("smp");
 | |
| +
 | |
|      DO_TEST_FULL("restore-v1", 0, "stdio");
 | |
|      DO_TEST_FULL("restore-v2", 0, "stdio");
 | |
|      DO_TEST_FULL("restore-v2", 0, "exec:cat");
 | |
| diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smp.args b/tests/qemuxml2argvdata/qemuxml2argv-smp.args
 | |
| new file mode 100644
 | |
| index 0000000..3ec8f15
 | |
| --- /dev/null
 | |
| +++ b/tests/qemuxml2argvdata/qemuxml2argv-smp.args
 | |
| @@ -0,0 +1 @@
 | |
| +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1,maxcpus=2,sockets=2,cores=1,threads=1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
 | |
| diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
 | |
| index 92d5b18..551d6c4 100644
 | |
| --- a/tests/qemuxml2argvtest.c
 | |
| +++ b/tests/qemuxml2argvtest.c
 | |
| @@ -385,6 +385,8 @@ mymain(int argc, char **argv)
 | |
| 
 | |
|      DO_TEST("qemu-ns", 0);
 | |
| 
 | |
| +    DO_TEST("smp", QEMUD_CMD_FLAG_SMP_TOPOLOGY);
 | |
| +
 | |
|      free(driver.stateDir);
 | |
|      virCapabilitiesFree(driver.caps);
 | |
| 
 | |
| diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
 | |
| index a33d435..cdc4390 100644
 | |
| --- a/tests/qemuxml2xmltest.c
 | |
| +++ b/tests/qemuxml2xmltest.c
 | |
| @@ -180,6 +180,8 @@ mymain(int argc, char **argv)
 | |
|      DO_TEST("encrypted-disk");
 | |
|      DO_TEST("memtune");
 | |
| 
 | |
| +    DO_TEST("smp");
 | |
| +
 | |
|      /* These tests generate different XML */
 | |
|      DO_TEST_DIFFERENT("balloon-device-auto");
 | |
|      DO_TEST_DIFFERENT("channel-virtio-auto");
 | |
| -- 
 | |
| 1.7.2.3
 | |
| 
 |