Re: [libvirt] Problem with setting up KVM guests to use HugePages
by Michal Privoznik
[please keep the list CC'ed]
On 10.06.2015 20:09, Clarylin L wrote:
> Hi Michal,
>
> Thanks a lot.
>
> If 100 hugepages are pre-allocated, the guest can start without decreasing
> number of hugepages. Since the guest requires 128 hugepages, it's kind of
> expected that the guest would not take memory from hugepages.
>
> Before guest start,
>
> [root@local ~]# cat /proc/meminfo | grep uge
>
> AnonH*uge*Pages: 0 kB
>
> H*uge*Pages_Total: 100
>
> H*uge*Pages_Free: 100
>
> H*uge*Pages_Rsvd: 0
>
> H*uge*Pages_Surp: 0
> H*uge*pagesize: 1048576 kB
>
> After:
>
> [root@local ~]# cat /proc/meminfo | grep uge
>
> AnonH*uge*Pages: 134254592 kB
>
> H*uge*Pages_Total: 100
>
> H*uge*Pages_Free: 100
>
> H*uge*Pages_Rsvd: 0
>
> H*uge*Pages_Surp: 0
> H*uge*pagesize: 1048576 kB
>
> There is no -mem-prealloc and -mem-path options in qemu command
And there can't be. From the command line below, you are defining 2 NUMA
nodes for your guest. In order to instruct qemu to back their memory by
huge pages you need it to support memory-backend-file object which was
introduced in qemu-2.1.0.
The other option you have is to not use guest NUMA nodes, in which case
global -mem-path can be used.
>
> [root@local ~]# ps -ef | grep qemu
>
> *qemu* 3403 1 99 17:42 ? 00:36:42 /usr/libexec/*qemu*-kvm
> -name qvpc-di-03-sf -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu
> host -m 131072 -realtime mlock=off -smp 32,sockets=2,cores=16,threads=1
> -numa node,nodeid=0,cpus=0-15,mem=65536 -numa
> node,nodeid=1,cpus=16-31,mem=65536 -uuid
> e1b72349-4a0b-4b91-aedc-fd34e92251e4 -smbios type=1,serial=SCALE-SLOT-03
> -no-user-config -nodefaults -chardev
> socket,id=charmonitor,path=/var/lib/libvirt/*qemu*/qvpc-di-03-sf.monitor,server,nowait
> -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown
> -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive
> file=/var/lib/libvirt/images/asr5700/qvpc-di-03-sf-hda.img,if=none,id=drive-ide0-0-0,format=qcow2
> -device
> ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive
> if=none,id=drive-ide0-1-0,readonly=on,format=raw -device
> ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
> -chardev pty,id=charserial0 -device
> isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1
> -device isa-serial,chardev=charserial1,id=serial1 -vnc 127.0.0.1:0 -vga
> cirrus -device i6300esb,id=watchdog0,bus=pci.0,addr=0x3 -watchdog-action
> reset -device vfio-pci,host=08:00.0,id=hostdev0,bus=pci.0,addr=0x5 -device
> vfio-pci,host=09:00.0,id=hostdev1,bus=pci.0,addr=0x6 -device
> vfio-pci,host=0a:00.0,id=hostdev2,bus=pci.0,addr=0x7 -device
> virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 -msg timestamp=on
>
>
> If 140 hugepages are preallocated, the guest cannot start and it complained
> not enough memory.
>
>
> The libvirt version is shown as follows:
>
> virsh # version
>
> Compiled against library: libvirt 1.2.8
>
> Using library: libvirt 1.2.8
>
> Using API: QEMU 1.2.8
>
> Running hypervisor: QEMU 1.5.3
>
>
> Also in guest configuration contains numa session. The hugepages are
> uniformly distributed to two nodes. In this case, do I need to make
> additional configurations to enable usage of hugepages?
>
> <numatune>
>
> <memory mode='strict' nodeset='0-1'/>
>
> </numatune>
>
This says that all the memory for you guests should be pinned onto host
nodes 0-1. If you want to be more specific, you can explicitly wire
guest NUMA nodes onto host NUMA nodes in 1:N relationship (where N can
be even 1, in which case you will get 1:1), e.g.:
<memnode cellid='0' mode='preferred' nodeset='0'/>
Michal
9 years, 7 months
[libvirt] [PATCH] schema: use arch list from basictypes for os arch attribute
by James Cowgill
I see no reason to duplicate this list of architectures. This also allows
more guest architectures to be used with libvirt (like the mips64el qemu
machine I am trying to run).
Signed-off-by: James Cowgill <james410(a)cowgill.org.uk>
---
docs/schemas/domaincommon.rng | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7c6fa5c..fc28fb3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -331,7 +331,9 @@
<define name="ostypehvm">
<element name="type">
<optional>
- <ref name="archList"/>
+ <attribute name="arch">
+ <ref name="archnames"/>
+ </attribute>
</optional>
<optional>
<attribute name="machine">
@@ -344,29 +346,13 @@
</element>
</define>
- <define name="archList">
- <attribute name="arch">
- <choice>
- <value>armv7l</value>
- <value>aarch64</value>
- <value>i686</value>
- <value>x86_64</value>
- <value>mips</value>
- <value>ppc</value>
- <value>ppc64</value>
- <value>ppc64le</value>
- <value>s390</value>
- <value>s390x</value>
- <value>sparc</value>
- </choice>
- </attribute>
- </define>
-
<define name="osexe">
<element name="os">
<element name="type">
<optional>
- <ref name="archList"/>
+ <attribute name="arch">
+ <ref name="archnames"/>
+ </attribute>
</optional>
<value>exe</value>
</element>
--
2.1.4
9 years, 7 months
[libvirt] [RFC PATCH] qemu: Use heads parameter for QXL driver
by Frediano Ziglio
Allow to specify maximum number of head to QXL driver.
Signed-off-by: Frediano Ziglio <fziglio(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 11 +++++++++++
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 8 ++++++++
tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 8 ++++++++
17 files changed, 77 insertions(+)
The patch to support the "max_outputs" in Qemu is still not merged but
I got agreement on the name of the argument.
Actually can be a compatiblity problem as heads in the XML configuration
was set by default to '1'.
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ca7a7c2..cdc2575 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -285,6 +285,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"dea-key-wrap",
"pci-serial",
"aarch64-off",
+ "qxl-vga.max_outputs",
);
@@ -1643,6 +1644,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxl[] = {
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxlVga[] = {
{ "vgamem_mb", QEMU_CAPS_QXL_VGA_VGAMEM },
+ { "max_outputs", QEMU_CAPS_QXL_VGA_MAX_OUTPUTS },
};
struct virQEMUCapsObjectTypeProps {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index b5a7770..a2ea84b 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -229,6 +229,7 @@ typedef enum {
QEMU_CAPS_DEA_KEY_WRAP = 187, /* -machine dea_key_wrap */
QEMU_CAPS_DEVICE_PCI_SERIAL = 188, /* -device pci-serial */
QEMU_CAPS_CPU_AARCH64_OFF = 189, /* -cpu ...,aarch64=off */
+ QEMU_CAPS_QXL_VGA_MAX_OUTPUTS = 190, /* qxl-vga.max_outputs */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0a6d92f..2bd63e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5610,6 +5610,11 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
/* QEMU accepts mebibytes for vgamem_mb. */
virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vgamem / 1024);
}
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) &&
+ video->heads > 0) {
+ virBufferAsprintf(&buf, ",max_outputs=%u", video->heads);
+ }
} else if (video->vram &&
((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
@@ -10234,6 +10239,7 @@ qemuBuildCommandLine(virConnectPtr conn,
unsigned int ram = def->videos[0]->ram;
unsigned int vram = def->videos[0]->vram;
unsigned int vgamem = def->videos[0]->vgamem;
+ unsigned int heads = def->videos[0]->heads;
if (vram > (UINT_MAX / 1024)) {
virReportError(VIR_ERR_OVERFLOW,
@@ -10264,6 +10270,11 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
dev, vgamem / 1024);
}
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) && heads > 0) {
+ virCommandAddArg(cmd, "-global");
+ virCommandAddArgFormat(cmd, "%s.max_outputs=%u",
+ dev, heads);
+ }
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index 30239df..7791e42 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -120,4 +120,5 @@
<flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
index f501218..aa1d3f9 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
@@ -1488,6 +1488,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "vgamem_mb",
"type": "uint32"
},
@@ -1554,6 +1558,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "vgamem_mb",
"type": "uint32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index ea3d850..bf4c731 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -135,4 +135,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.replies b/tests/qemucapabilitiesdata/caps_1.3.1-1.replies
index e1f9704..6e210fe 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.replies
@@ -1659,6 +1659,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1729,6 +1733,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index 2c19ddc..a371b57 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -136,4 +136,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.replies b/tests/qemucapabilitiesdata/caps_1.4.2-1.replies
index 3d797b2..2b97937 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.replies
@@ -1706,6 +1706,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1776,6 +1780,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index aadccd5..bb3d7aa 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -145,4 +145,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.replies b/tests/qemucapabilitiesdata/caps_1.5.3-1.replies
index 45571a3..1a67ab9 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.replies
@@ -1780,6 +1780,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1850,6 +1854,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index 3e81cbf..9d98f13 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -151,4 +151,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.replies b/tests/qemucapabilitiesdata/caps_1.6.0-1.replies
index ae4b3f4..3b187c5 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.replies
@@ -1842,6 +1842,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1912,6 +1916,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 84c357f..ac1a3bd 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -151,4 +151,5 @@
<flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.replies b/tests/qemucapabilitiesdata/caps_1.6.50-1.replies
index 90d31f0..52ddebb 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.replies
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.replies
@@ -1806,6 +1806,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -1876,6 +1880,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
index b1ee8df..df23c28 100644
--- a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
@@ -167,4 +167,5 @@
<flag name='qxl-vga.vgamem_mb'/>
<flag name='pc-dimm'/>
<flag name='pci-serial'/>
+ <flag name='qxl-vga.max_outputs'/>
</qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.replies b/tests/qemucapabilitiesdata/caps_2.1.1-1.replies
index 511461a..863003f 100644
--- a/tests/qemucapabilitiesdata/caps_2.1.1-1.replies
+++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.replies
@@ -2252,6 +2252,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
@@ -2322,6 +2326,10 @@
"type": "pci-devfn"
},
{
+ "name": "max_outputs",
+ "type": "uint16"
+ },
+ {
"name": "surfaces",
"type": "int32"
},
--
2.1.0
9 years, 7 months
[libvirt] [(python) PATCH 0/2] Provide symbolic names for typed parameters
by Jiri Denemark
libvirt:
Jiri Denemark (1):
apibuild: Generate macro/@string attribute
docs/apibuild.py | 47 ++++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)
libvirt-python:
Jiri Denemark (1):
Provide symbolic names for typed parameters
generator.py | 8 ++++++++
1 file changed, 8 insertions(+)
--
2.4.2
9 years, 7 months
[libvirt] [PATCH] parallels: implement attach/detach network.
by Mikhail Feoktistov
Support nova commands interface-attach and interface-detach.
For containers only.
I use memcmp() to compare MAC addresses,
because PrlVmDevNet_GetMacAddress() returns MAC as a UTF-8 encoded,
null-terminated string.
---
src/parallels/parallels_driver.c | 16 ++++
src/parallels/parallels_sdk.c | 144 +++++++++++++++++++++++++++++++++++++-
src/parallels/parallels_sdk.h | 4 +
3 files changed, 161 insertions(+), 3 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 706229d..0009127 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -1117,6 +1117,14 @@ static int parallelsDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup;
}
break;
+ case VIR_DOMAIN_DEVICE_NET:
+ ret = prlsdkAttachNet(privdom, privconn, dev->data.net);
+ if (ret) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("network attach failed"));
+ goto cleanup;
+ }
+ break;
default:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("device type '%s' cannot be attached"),
@@ -1186,6 +1194,14 @@ static int parallelsDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup;
}
break;
+ case VIR_DOMAIN_DEVICE_NET:
+ ret = prlsdkDetachNet(privdom, privconn, dev->data.net);
+ if (ret) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("network detach failed"));
+ goto cleanup;
+ }
+ break;
default:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("device type '%s' cannot be detached"),
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 104c905..306f5e3 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2815,6 +2815,12 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
prlsdkCheckRetGoto(pret, cleanup);
+ pret = PrlVmDevNet_SetConfigureWithDhcp(sdknet, true);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ pret = PrlVmDevNet_SetAutoApply(sdknet, true);
+ prlsdkCheckRetGoto(pret, cleanup);
+
if (isCt) {
if (net->model)
VIR_WARN("Setting network adapter for containers is not "
@@ -2885,14 +2891,15 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
return ret;
}
-static void prlsdkDelNet(parallelsConnPtr privconn, virDomainNetDefPtr net)
+static int prlsdkDelNet(parallelsConnPtr privconn, virDomainNetDefPtr net)
{
+ int ret = -1;
PRL_RESULT pret;
PRL_HANDLE vnet = PRL_INVALID_HANDLE;
PRL_HANDLE job = PRL_INVALID_HANDLE;
if (net->type != VIR_DOMAIN_NET_TYPE_BRIDGE)
- return;
+ return 0;
pret = PrlVirtNet_Create(&vnet);
prlsdkCheckRetGoto(pret, cleanup);
@@ -2900,12 +2907,142 @@ static void prlsdkDelNet(parallelsConnPtr privconn, virDomainNetDefPtr net)
pret = PrlVirtNet_SetNetworkId(vnet, net->data.network.name);
prlsdkCheckRetGoto(pret, cleanup);
- PrlSrv_DeleteVirtualNetwork(privconn->server, vnet, 0);
+ job = PrlSrv_DeleteVirtualNetwork(privconn->server, vnet, 0);
if (PRL_FAILED(pret = waitJob(job)))
goto cleanup;
+ ret = 0;
+
cleanup:
PrlHandle_Free(vnet);
+ return ret;
+}
+
+int prlsdkAttachNet(virDomainObjPtr dom, parallelsConnPtr privconn, virDomainNetDefPtr net)
+{
+ int ret = -1;
+ parallelsDomObjPtr privdom = dom->privateData;
+ PRL_HANDLE job = PRL_INVALID_HANDLE;
+
+ if (!IS_CT(dom->def)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("network device cannot be attached"));
+ goto cleanup;
+ }
+
+ job = PrlVm_BeginEdit(privdom->sdkdom);
+ if (PRL_FAILED(waitJob(job)))
+ goto cleanup;
+
+ ret = prlsdkAddNet(privdom->sdkdom, privconn, net, IS_CT(dom->def));
+ if (ret == 0) {
+ job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
+ if (PRL_FAILED(waitJob(job))) {
+ ret = -1;
+ goto cleanup;
+ }
+ }
+
+ cleanup:
+ return ret;
+}
+
+static int
+prlsdkGetNetIndex(PRL_HANDLE sdkdom, virDomainNetDefPtr net)
+{
+ int idx = -1;
+ PRL_RESULT pret;
+ PRL_UINT32 netCount;
+ PRL_UINT32 i;
+ PRL_HANDLE adapter = PRL_INVALID_HANDLE;
+ PRL_UINT32 len;
+ char adapterMac[PRL_MAC_STRING_BUFNAME];
+ char netMac[PRL_MAC_STRING_BUFNAME];
+
+ prlsdkFormatMac(&net->mac, netMac);
+ pret = PrlVmCfg_GetNetAdaptersCount(sdkdom, &netCount);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ for (i = 0; i < netCount; ++i) {
+
+ pret = PrlVmCfg_GetNetAdapter(sdkdom, i, &adapter);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ len = sizeof(adapterMac);
+ memset(adapterMac, 0, sizeof(adapterMac));
+ pret = PrlVmDevNet_GetMacAddress(adapter, adapterMac, &len);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ if (memcmp(adapterMac, netMac, PRL_MAC_STRING_BUFNAME)) {
+
+ PrlHandle_Free(adapter);
+ adapter = PRL_INVALID_HANDLE;
+ continue;
+ }
+
+ idx = i;
+ break;
+ }
+
+ cleanup:
+ PrlHandle_Free(adapter);
+ return idx;
+}
+
+static int prlsdkDelNetAdapter(PRL_HANDLE sdkdom, int idx)
+{
+ int ret = -1;
+ PRL_RESULT pret;
+ PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
+
+ pret = PrlVmCfg_GetNetAdapter(sdkdom, idx, &sdknet);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ pret = PrlVmDev_Remove(sdknet);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ ret = 0;
+
+ cleanup:
+ PrlHandle_Free(sdknet);
+ return ret;
+}
+
+int prlsdkDetachNet(virDomainObjPtr dom, parallelsConnPtr privconn, virDomainNetDefPtr net)
+{
+ int ret = -1, idx = -1;
+ parallelsDomObjPtr privdom = dom->privateData;
+ PRL_HANDLE job = PRL_INVALID_HANDLE;
+
+ if (!IS_CT(dom->def)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("network device cannot be detached"));
+ goto cleanup;
+ }
+
+ idx = prlsdkGetNetIndex(privdom->sdkdom, net);
+ if (idx < 0)
+ goto cleanup;
+
+ job = PrlVm_BeginEdit(privdom->sdkdom);
+ if (PRL_FAILED(waitJob(job)))
+ goto cleanup;
+
+ ret = prlsdkDelNet(privconn, net);
+ if (ret != 0)
+ goto cleanup;
+
+ ret = prlsdkDelNetAdapter(privdom->sdkdom, idx);
+ if (ret == 0) {
+ job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
+ if (PRL_FAILED(waitJob(job))) {
+ ret = -1;
+ goto cleanup;
+ }
+ }
+
+ cleanup:
+ return ret;
}
static int prlsdkDelDisk(PRL_HANDLE sdkdom, int idx)
@@ -3150,6 +3287,7 @@ prlsdkGetDiskIndex(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
pret = PrlVmCfg_GetHardDisk(sdkdom, i, &hdd);
prlsdkCheckRetGoto(pret, cleanup);
+ buflen = 0;
pret = PrlVmDev_GetFriendlyName(hdd, 0, &buflen);
prlsdkCheckRetGoto(pret, cleanup);
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index afa6745..6708fd4 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -66,3 +66,7 @@ int
prlsdkDetachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
int
prlsdkGetBlockStats(virDomainObjPtr dom, virDomainDiskDefPtr disk, virDomainBlockStatsPtr stats);
+int
+prlsdkAttachNet(virDomainObjPtr dom, parallelsConnPtr privconn, virDomainNetDefPtr net);
+int
+prlsdkDetachNet(virDomainObjPtr dom, parallelsConnPtr privconn, virDomainNetDefPtr net);
--
1.7.1
9 years, 7 months
[libvirt] [PATCH v2 0/4] Add support for vhost-user with multi-queue
by Martin Kletzander
Also some tiny clean-up.
Martin Kletzander (2):
conf: Ignore multiqueue with one queue.
qemu: Add capability for vhost-user multiqueue
Maxime Leroy (2):
docs: Clarify that attribute name is not used for vhostuser
qemu: add multiqueue vhost-user support
docs/formatdomain.html.in | 16 ++++++++++++++--
src/conf/domain_conf.c | 3 ++-
src/qemu/qemu_capabilities.c | 6 ++++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 14 +++++++++++++-
...tuser.args => qemuxml2argv-net-vhostuser-multiq.args} | 6 +++++-
...ostuser.xml => qemuxml2argv-net-vhostuser-multiq.xml} | 6 ++++++
.../qemuxml2argv-tap-vhost-incorrect.xml | 6 ++++++
tests/qemuxml2argvtest.c | 3 +++
.../qemuxml2xmlout-tap-vhost-incorrect.xml | 6 ++++++
10 files changed, 62 insertions(+), 5 deletions(-)
copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.args => qemuxml2argv-net-vhostuser-multiq.args} (75%)
copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.xml => qemuxml2argv-net-vhostuser-multiq.xml} (87%)
--
2.4.2
9 years, 7 months
[libvirt] [PATCH 0/8] logically memory hotplug via guest agent
by Zhang Bo
Logically memory hotplug via guest agent, by enabling/disabling memory blocks.
The corresponding qga commands are: 'guest-get-memory-blocks',
'guest-set-memory-blocks' and 'guest-get-memory-block-info'.
detailed flow:
1 get memory block list, each member has 'phy-index', 'online' and 'can-offline' parameters
2 get memory block size, normally 128MB or 256MB for most OSes
3 convert the target memory size to memory block number, and see if there's enough memory
blocks to be set online/offline.
4 update the memory block list info, and let guest agent to set memory blocks online/offline.
Note that because we hotplug memory logically by online/offline MEMORY BLOCKS,
and each memory block has a size much bigger than KiB, there's a deviation
with the range of (0, block_size). block_size may be 128MB or 256MB or etc.,
it differs on different OSes.
Zhang Bo (8):
lifecycle: add flag VIR_DOMAIN_MEM_GUEST for viDomainSetMemoryFlags
qemu: agent: define structure of qemuAgentMemblockInfo
qemu: agent: implement qemuAgentGetMemblocks
qemu: agent: implement qemuAgentGetMemblockGeneralInfo
qemu: agent: implement qemuAgentUpdateMemblocks
qemu: agent: implement function qemuAgetSetMemblocks
qemu: memory: logically hotplug memory with guest agent
virsh: support memory hotplug with guest agent in virsh
include/libvirt/libvirt-domain.h | 1 +
src/libvirt-domain.c | 7 +
src/qemu/qemu_agent.c | 307 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 22 +++
src/qemu/qemu_driver.c | 46 +++++-
tools/virsh-domain.c | 10 +-
tools/virsh.pod | 7 +-
7 files changed, 396 insertions(+), 4 deletions(-)
--
1.7.12.4
9 years, 7 months
[libvirt] [PATCH] add some more missing libvirt functions
by Vasiliy Tolstov
* libvirt_connect_get_all_domain_stats
* libvirt_domain_block_resize
* libvirt_domain_block_job_abort
* libvirt_domain_block_job_set_speed
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
src/libvirt-php.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/libvirt-php.h | 4 ++
2 files changed, 180 insertions(+), 1 deletion(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index e9b9657..f9096ef 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -91,6 +91,7 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_connect_get_maxvcpus, NULL)
PHP_FE(libvirt_connect_get_encrypted, NULL)
PHP_FE(libvirt_connect_get_secure, NULL)
+ PHP_FE(libvirt_connect_get_all_domain_stats, NULL)
/* Stream functions */
PHP_FE(libvirt_stream_create, NULL)
PHP_FE(libvirt_stream_close, NULL)
@@ -136,6 +137,10 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_domain_memory_peek,NULL)
PHP_FE(libvirt_domain_memory_stats,NULL)
PHP_FE(libvirt_domain_block_stats,NULL)
+ PHP_FE(libvirt_domain_block_resize,NULL)
+ // PHP_FE(libvirt_domain_block_copy,NULL)
+ PHP_FE(libvirt_domain_block_job_abort,NULL)
+ PHP_FE(libvirt_domain_block_job_set_speed,NULL)
PHP_FE(libvirt_domain_interface_stats,NULL)
PHP_FE(libvirt_domain_get_connect, NULL)
PHP_FE(libvirt_domain_migrate, NULL)
@@ -1332,6 +1337,11 @@ PHP_MINIT_FUNCTION(libvirt)
/* Job was aborted but it's not cleanup up yet */
REGISTER_LONG_CONSTANT("VIR_DOMAIN_JOB_CANCELLED", 5, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC", VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT", VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES", VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES, CONST_CS | CONST_PERSISTENT);
+
/* Migration constants */
REGISTER_LONG_CONSTANT("VIR_MIGRATE_LIVE", 1, CONST_CS | CONST_PERSISTENT);
/* direct source -> dest host control channel Note the less-common spelling that we're stuck with: */
@@ -1374,7 +1384,7 @@ PHP_MINIT_FUNCTION(libvirt)
REGISTER_LONG_CONSTANT("VIR_DOMAIN_FLAG_TEST_LOCAL_VNC", DOMAIN_FLAG_TEST_LOCAL_VNC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_FLAG_SOUND_AC97", DOMAIN_FLAG_SOUND_AC97, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_FILE", DOMAIN_DISK_FILE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_BLOCK", DOMAIN_DISK_BLOCK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_BLOCK", DOMAIN_DISK_BLOCK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_ACCESS_ALL", DOMAIN_DISK_ACCESS_ALL, CONST_CS | CONST_PERSISTENT);
/* Domain metadata constants */
@@ -1385,6 +1395,24 @@ PHP_MINIT_FUNCTION(libvirt)
REGISTER_LONG_CONSTANT("VIR_DOMAIN_AFFECT_LIVE", 1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_AFFECT_CONFIG", 2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_STATE", VIR_DOMAIN_STATS_STATE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_CPU_TOTAL", VIR_DOMAIN_STATS_CPU_TOTAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_BALLOON", VIR_DOMAIN_STATS_BALLOON, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_VCPU", VIR_DOMAIN_STATS_VCPU, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_INTERFACE", VIR_DOMAIN_STATS_INTERFACE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_BLOCK", VIR_DOMAIN_STATS_BLOCK, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE", VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE", VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER", VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED", VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT", VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING", VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF", VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT", VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT, CONST_CS | CONST_PERSISTENT);
+ // REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING", VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS", VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, CONST_CS | CONST_PERSISTENT);
+
/* Connect flags */
REGISTER_LONG_CONSTANT("VIR_CONNECT_FLAG_SOUNDHW_GET_NAMES", CONNECT_FLAG_SOUNDHW_GET_NAMES, CONST_CS | CONST_PERSISTENT);
@@ -2425,6 +2453,69 @@ PHP_FUNCTION(libvirt_connect_get_secure)
RETURN_LONG( virConnectIsSecure(conn->conn) );
}
+
+/*
+ Function name: libvirt_connect_get_all_domain_stats
+ Since version: 0.5.1(-1)
+ Description: Query statistics for all domains on a given connection
+ Arguments:��� @conn [resource]: resource for connection
+ @stats [int]: the statistic groups from VIR_DOMAIN_STATS_*
+ @flags [int]: the filter flags from VIR_CONNECT_GET_ALL_DOMAINS_STATS_*
+ Returns: assoc array with statistics or false on error
+*/
+PHP_FUNCTION(libvirt_connect_get_all_domain_stats)
+{
+ php_libvirt_connection *conn = NULL;
+ zval *zconn;
+ int retval = -1;
+ long flags = 0;
+ long stats = 0;
+ char *name = NULL;
+ int i;
+ int j;
+ virTypedParameter params;
+ virDomainStatsRecordPtr *retstats = NULL;
+
+ GET_CONNECTION_FROM_ARGS("r|l|l",&zconn, &stats, &flags);
+
+ retval = virConnectGetAllDomainStats(conn->conn, stats, &retstats, flags);
+
+ array_init(return_value);
+ if (retval < 0)
+ RETURN_FALSE;
+
+ for (i=0; i < retval; i++) {
+ zval *arr2;
+ ALLOC_INIT_ZVAL(arr2);
+ array_init(arr2);
+ for (j = 0; j < retstats[i]->nparams; j++) {
+ params = retstats[i]->params[j];
+ switch (params.type) {
+ case VIR_TYPED_PARAM_INT:
+ add_assoc_long(arr2, params.field, params.value.i);
+ case VIR_TYPED_PARAM_UINT:
+ add_assoc_long(arr2, params.field, params.value.ui);
+ case VIR_TYPED_PARAM_LLONG:
+ add_assoc_long(arr2, params.field, params.value.l);
+ case VIR_TYPED_PARAM_ULLONG:
+ add_assoc_long(arr2, params.field, params.value.ul);
+ case VIR_TYPED_PARAM_DOUBLE:
+ add_assoc_double(arr2, params.field, params.value.d);
+ case VIR_TYPED_PARAM_BOOLEAN:
+ add_assoc_bool(arr2, params.field, params.value.b);
+ case VIR_TYPED_PARAM_STRING:
+ add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s, strlen(params.value.s)+1);
+ }
+ }
+ name = virDomainGetName(retstats[i]->dom);
+ zend_hash_update(Z_ARRVAL_P(return_value), name, strlen(name)+1, &arr2, sizeof(arr2), NULL);
+ }
+
+ virDomainStatsRecordListFree(retstats);
+}
+
+
+
/*
Function name: libvirt_connect_get_maxvcpus
Since version: 0.4.1(-2)
@@ -5990,6 +6081,90 @@ PHP_FUNCTION(libvirt_domain_block_stats)
}
/*
+ Function name: libvirt_domain_block_resize
+ Since version: 0.5.1(-1)
+ Description: Function is used to resize the domain's block device
+ Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+ @path [string]: device path to resize
+ @size [int]: size of device
+ @flags [int]: bitwise-OR of VIR_DOMAIN_BLOCK_RESIZE_*
+ Returns: true on success fail on error
+*/
+PHP_FUNCTION(libvirt_domain_block_resize)
+{
+ php_libvirt_domain *domain=NULL;
+ zval *zdomain;
+ int retval;
+ char *path;
+ int path_len;
+ long size = 0;
+ long flags = 0;
+
+ GET_DOMAIN_FROM_ARGS("rsl|l",&zdomain,&path,&path_len, &size, &flags);
+
+ retval=virDomainBlockResize(domain->domain,path, size, flags);
+ if (retval == -1) RETURN_FALSE;
+
+ RETURN_TRUE;
+}
+
+/*
+ Function name: libvirt_domain_block_job_abort
+ Since version: 0.5.1(-1)
+ Description: Function is used to abort block job
+ Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+ @path [string]: device path to resize
+ @flags [int]: bitwise-OR of VIR_DOMAIN_BLOCK_JOB_ABORT_*
+ Returns: true on success fail on error
+*/
+PHP_FUNCTION(libvirt_domain_block_job_abort)
+{
+ php_libvirt_domain *domain=NULL;
+ zval *zdomain;
+ int retval;
+ char *path;
+ int path_len;
+ long flags = 0;
+
+ GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&path,&path_len, &flags);
+
+ retval=virDomainBlockJobAbort(domain->domain,path, flags);
+ if (retval == -1) RETURN_FALSE;
+
+ RETURN_TRUE;
+}
+
+/*
+ Function name: libvirt_domain_block_job_set_speed
+ Since version: 0.5.1(-1)
+ Description: Function is used to set speed of block job
+ Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+ @path [string]: device path to resize
+ @bandwidth [int]: bandwidth
+ @flags [int]: bitwise-OR of VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_*
+ Returns: true on success fail on error
+*/
+PHP_FUNCTION(libvirt_domain_block_job_set_speed)
+{
+ php_libvirt_domain *domain=NULL;
+ zval *zdomain;
+ int retval;
+ char *path;
+ int path_len;
+ long bandwidth = 0;
+ long flags = 0;
+
+ GET_DOMAIN_FROM_ARGS("rsl|l",&zdomain,&path,&path_len, &bandwidth, &flags);
+
+ retval=virDomainBlockJobSetSpeed(domain->domain,path, bandwidth, flags);
+ if (retval == -1) RETURN_FALSE;
+
+ RETURN_TRUE;
+}
+
+
+
+/*
Function name: libvirt_domain_get_network_info
Since version: 0.4.1(-1)
Description: Function is used to get the domain's network information
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 3bcc682..a197b4b 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -349,6 +349,7 @@ PHP_FUNCTION(libvirt_connect_get_encrypted);
PHP_FUNCTION(libvirt_connect_get_secure);
PHP_FUNCTION(libvirt_connect_get_information);
PHP_FUNCTION(libvirt_connect_get_machine_types);
+PHP_FUNCTION(libvirt_connect_get_all_domain_stats);
/* Node functions */
PHP_FUNCTION(libvirt_node_get_info);
PHP_FUNCTION(libvirt_node_get_cpu_stats);
@@ -403,6 +404,9 @@ PHP_FUNCTION(libvirt_domain_memory_peek);
PHP_FUNCTION(libvirt_domain_memory_stats);
PHP_FUNCTION(libvirt_domain_update_device);
PHP_FUNCTION(libvirt_domain_block_stats);
+PHP_FUNCTION(libvirt_domain_block_resize);
+PHP_FUNCTION(libvirt_domain_block_job_abort);
+PHP_FUNCTION(libvirt_domain_block_job_set_speed);
PHP_FUNCTION(libvirt_domain_interface_stats);
PHP_FUNCTION(libvirt_domain_get_connect);
PHP_FUNCTION(libvirt_domain_migrate);
--
2.3.3
9 years, 7 months
[libvirt] question about virConnectGetAllDomainStats and virTypedParameter
by Vasiliy Tolstov
I'm try to implement virConnectGetAllDomainStats for php binding api,
but have one issue with VIR_TYPED_PARAM_STRING:
code part:
retval = virConnectGetAllDomainStats(conn->conn, stats,
&retstats, flags);
for (i=0; i < retval; i++) {
zval *arr2;
ALLOC_INIT_ZVAL(arr2);
array_init(arr2);
for (j = 0; j < retstats[i]->nparams; j++) {
params = retstats[i]->params[j];
switch (params.type) {
case VIR_TYPED_PARAM_INT:
add_assoc_long(arr2, params.field,
params.value.i);
case VIR_TYPED_PARAM_UINT:
add_assoc_long(arr2, params.field,
params.value.ui);
case VIR_TYPED_PARAM_LLONG:
add_assoc_long(arr2, params.field,
params.value.l);
case VIR_TYPED_PARAM_ULLONG:
add_assoc_long(arr2, params.field,
params.value.ul);
case VIR_TYPED_PARAM_DOUBLE:
add_assoc_double(arr2, params.field,
params.value.d);
case VIR_TYPED_PARAM_BOOLEAN:
add_assoc_bool(arr2, params.field,
params.value.b);
case VIR_TYPED_PARAM_STRING:
add_assoc_string_ex(arr2,
params.field, strlen(params.field)+1, strdup(params.value.s),
strlen(params.value.s)+1); // SEGFAULT HAPPENING
}
}
gdb shows:
return_value_used=<optimized out>) at libvirt-php.c:2505
arr2 = 0x7ffff7fd72b8
conn = <optimized out>
zconn = 0x7ffff7fd7140
retval = <optimized out>
flags = <optimized out>
stats = <optimized out>
name = <optimized out>
i = <optimized out>
j = <optimized out>
params = {field = "state.state", '\000' <repeats 68 times>,
type = 1, value = {i = 5, ui = 5, l = 5, ul = 5, d =
2.4703282292062327e-323, b = 5 '\005',
s = 0x5 <Address 0x5 out of bounds>}}
retstats = 0x101d870
What i'm doing wrong?
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
9 years, 7 months
[libvirt] Problem with setting up KVM guests to use HugePages
by Vivi L
Configure hugepages and then start virtual guest via "virsh start". However,
virtual guest failed to use hugepages although it's configured
The initial usage of system memory
[root@local ~]# free
total used free shared buff/cache available
Mem: 263767352 1900628 261177892 9344 688832 261431872
Swap: 4194300 0 4194300
After configuring hugepages,
[root@local ~]# cat /proc/meminfo | grep uge
AnonHugePages: 2048 kB
HugePages_Total: 140
HugePages_Free: 140
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 1048576 kB
[root@local ~]# mount | grep huge
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,
relatime,hugetlb)hugetlbfs on /dev/hugepages type hugetlbfs (rw,realtime)
On the guest side, its config xml contains
<domain type='kvm'>
<name>test-01</name>
<uuid>e1b72349-4a0b-4b91-aedc-fd34e92251e4</uuid>
<description>test-01</description>
<memory unit='KiB'>134217728</memory>
<currentMemory unit='KiB'>134217728</currentMemory>
<memoryBacking>
<hugepages/>
<nosharepages/>
</memoryBacking>
Tried to virsh start the guest, but it failed although the hugepages memory
was sufficient
virsh # start test-01
error: Failed to start domain test-01
error: internal error: early end of file from monitor: possible problem:
Cannot set up guest memory 'pc.ram': Cannot allocate memory
however, if decrease the number of hugepages to smaller(say 100) that
makes the memory not used by hugepages more than required by guest,
then guest can start. But memory is not allocated from hugepages.
[root@local ~]# cat /proc/meminfo | grep uge
AnonHugePages: 134254592 kB
HugePages_Total: 100
HugePages_Free: 100
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 1048576 kB
In summary, although hugepages is configured, the guest seemed not
instructed to use hugepage, instead, the guest is allocated memory from
the memory pool leftover by hugepages.
9 years, 7 months