[libvirt] [[libvirt-php][PATCH v2] qemu-agent-command] fixes for installation and add another libvirt function
by Vasiliy Tolstov
* add libvirt_domain_qemu_agent_command
* fix install target, because before this all stuff goes to /usr/usr dir
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
configure.ac | 3 +++
src/Makefile.am | 19 ++++++++++---------
src/libvirt-php.c | 28 ++++++++++++++++++++++++++++
src/libvirt-php.h | 2 ++
4 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9e9fee0..0afa2e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,9 @@ PKG_PROG_PKG_CONFIG
LIBVIRT_REQUIRED=0.6.2
PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
+PKG_CHECK_MODULES(QEMU, libvirt-qemu)
+AC_SUBST([QEMU_CFLAGS])
+AC_SUBST([QEMU_LIBS])
dnl ==========================================================================
dnl required minimum version of libxml2
diff --git a/src/Makefile.am b/src/Makefile.am
index cab0456..f270ec2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,10 +6,10 @@ WL=@WL@
SHLIB_FLAGS=@SHLIB_FLAGS@
install-exec-local:
- $(MKDIR_P) $(DESTDIR)$(prefix)$(PHPEDIR)
- $(MKDIR_P) $(DESTDIR)$(prefix)$(PHPCDIR)
- $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(prefix)$(PHPEDIR)/$(PACKAGE).so
- $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)$(PHPCDIR)
+ $(MKDIR_P) $(DESTDIR)$(PHPEDIR)
+ $(MKDIR_P) $(DESTDIR)$(PHPCDIR)
+ $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so
+ $(INSTALL) -m 755 -d $(DESTDIR)$(PHPCDIR)
$(ECHO) "extension=$(PACKAGE).so" > libvirt-php.ini
$(ECHO) >> libvirt-php.ini
$(ECHO) "[libvirt]" >> libvirt-php.ini
@@ -19,21 +19,22 @@ install-exec-local:
$(ECHO) "libvirt.image_path=/var/lib/libvirt/images" >> libvirt-php.ini
$(ECHO) "; Limit maximum number of libvirt connections" >> libvirt-php.ini
$(ECHO) "libvirt.max_connections=5" >> libvirt-php.ini
- $(INSTALL) -m 644 -D libvirt-php.ini $(DESTDIR)$(prefix)$(PHPCDIR)/$(PACKAGE).ini
+ $(INSTALL) -m 644 -D libvirt-php.ini $(DESTDIR)$(PHPCDIR)/$(PACKAGE).ini
uninstall-local:
- $(RM) -f $(DESTDIR)$(prefix)$(PHPCDIR)/$(PACKAGE).ini
- $(RM) -f $(DESTDIR)$(prefix)$(PHPEDIR)/$(PACKAGE).so
+ $(RM) -f $(DESTDIR)$(PHPCDIR)/$(PACKAGE).ini
+ $(RM) -f $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so
AM_CFLAGS = \
$(PHPINC) $(LIBXML_CFLAGS) \
- $(LIBVIRT_CFLAGS) $(DEFINES) \
+ $(LIBVIRT_CFLAGS) $(QEMU_CFLAGS) $(DEFINES) \
-I$(top_srcdir)/winsrc
AM_LDFLAGS = \
$(SHLIB_LDFLAGS) \
$(LIBXML_LIBS) \
- $(LIBVIRT_LIBS)
+ $(LIBVIRT_LIBS) \
+ $(QEMU_LIBS)
lib_LTLIBRARIES = libvirt-php.la
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index d46fbb9..f9d5557 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -161,6 +161,7 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_domain_send_keys, NULL)
PHP_FE(libvirt_domain_send_pointer_event, NULL)
PHP_FE(libvirt_domain_update_device, NULL)
+ PHP_FE(libvirt_domain_qemu_agent_command, NULL)
/* Domain snapshot functions */
PHP_FE(libvirt_domain_has_current_snapshot, NULL)
PHP_FE(libvirt_domain_snapshot_create, NULL)
@@ -3943,6 +3944,33 @@ PHP_FUNCTION(libvirt_domain_get_name)
}
/*
+ Function name: libvirt_domain_qemu_agent_command
+ Since version: 0.5.2(-1)
+ Description: Function is used to send qemu-ga command
+ Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+ @timeout [int]: timeout for waiting (-2 block, -1 default, 0 no wait, >0 wait specific time
+ @flags [int]: ??
+ Returns: String on success and FALSE on error
+*/
+PHP_FUNCTION(libvirt_domain_qemu_agent_command)
+{
+ php_libvirt_domain *domain=NULL;
+ zval *zdomain;
+ const char *cmd;
+ int cmd_len;
+ char *ret;
+ long timeout = -1;
+ long flags = 0;
+
+ GET_DOMAIN_FROM_ARGS("rs|l|l", &zdomain, &cmd, &cmd_len, &timeout, &flags);
+
+ ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags);
+ if (ret == NULL) RETURN_FALSE;
+
+ RETURN_STRING(ret,1);
+}
+
+/*
Function name: libvirt_domain_get_uuid_string
Since version: 0.4.1(-1)
Description: Function is used to get the domain's UUID in string format
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 7c9a229..1d9c6ab 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -80,6 +80,7 @@
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
+#include <libvirt/libvirt-qemu.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <fcntl.h>
@@ -427,6 +428,7 @@ PHP_FUNCTION(libvirt_domain_send_keys);
PHP_FUNCTION(libvirt_domain_send_pointer_event);
PHP_FUNCTION(libvirt_domain_get_metadata);
PHP_FUNCTION(libvirt_domain_set_metadata);
+PHP_FUNCTION(libvirt_domain_qemu_agent_command);
/* Domain snapshot functions */
PHP_FUNCTION(libvirt_domain_has_current_snapshot);
PHP_FUNCTION(libvirt_domain_snapshot_create);
--
2.3.3
9 years, 5 months
[libvirt] [PATCH] conf: Enforce scheduler name when parsing XML
by Peter Krempa
We require the scheduler name attribute in the schemas but the code
would actually be fine when it was omitted. Make it mandatory.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1234729
---
src/conf/domain_conf.c | 49 ++++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e592adf..183e66c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14153,32 +14153,35 @@ virDomainThreadSchedParse(xmlNodePtr node,
}
VIR_FREE(tmp);
- tmp = virXMLPropString(node, "scheduler");
- if (tmp) {
- if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid scheduler attribute: '%s'"),
- tmp);
+ if (!(tmp = virXMLPropString(node, "scheduler"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing scheduler attribute"));
+ goto error;
+ }
+
+ if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid scheduler attribute: '%s'"),
+ tmp);
+ goto error;
+ }
+ sp->policy = pol;
+
+ VIR_FREE(tmp);
+ if (sp->policy == VIR_PROC_POLICY_FIFO ||
+ sp->policy == VIR_PROC_POLICY_RR) {
+ tmp = virXMLPropString(node, "priority");
+ if (!tmp) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Missing scheduler priority"));
goto error;
}
- sp->policy = pol;
-
- VIR_FREE(tmp);
- if (sp->policy == VIR_PROC_POLICY_FIFO ||
- sp->policy == VIR_PROC_POLICY_RR) {
- tmp = virXMLPropString(node, "priority");
- if (!tmp) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("Missing scheduler priority"));
- goto error;
- }
- if (virStrToLong_i(tmp, NULL, 10, &sp->priority) < 0) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("Invalid value for element priority"));
- goto error;
- }
- VIR_FREE(tmp);
+ if (virStrToLong_i(tmp, NULL, 10, &sp->priority) < 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Invalid value for element priority"));
+ goto error;
}
+ VIR_FREE(tmp);
}
return 0;
--
2.4.1
9 years, 5 months
[libvirt] [PATCHv3 00/10] new API virDomainBlockSetWriteThreshold
by Eric Blake
v2 was here:
https://www.redhat.com/archives/libvir-list/2015-June/msg00591.html
This series depends on my yajl/json cleanups:
https://www.redhat.com/archives/libvir-list/2015-June/msg01098.html
and can also be found here:
git clone git://repo.or.cz/libvirt/ericb.git threshold
http://repo.or.cz/w/libvirt/ericb.git/shortlog/refs/heads/threshold
Since then, I've rebased to master, addressed Peter's findings on v2,
and tested that things actually work when combined with a single
pending patch on qemu (I'll reply to this mail with the list id of
that patch, where that patch in turn points to this series as
justification).
Here's a transcript of how I tested:
I modified my 'f20' domain to include:
<devices>
<emulator>/home/eblake/qemu/x86_64-softmmu/qemu-system-x86_64</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='qcow2'/>
<source dev='/dev/sda6'/>
<target dev='vda' bus='virtio'/>
</disk>
then created a raw partition wrapper around the usual disk image:
# qemu-img create -f qcow2 -o backing_file=/var/lib/libvirt/images/f20.img,backing_fmt=qcow2 /dev/sda6
Formatting '/dev/sda6', fmt=qcow2 size=12884901888 backing_file='/var/lib/libvirt/images/f20.img' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
I then started the domain paused (as long as no guest I/O happens,
the threshold cannot be exceeded, which gives me time to register
a threshold and set up an event handler):
# virsh start --paused f20
Domain f20 started
# ./run tools/virsh -k0 domblkthreshold f20 vda 10000
threshold of vda set to 10000 bytes
I was then able to play with domstats to see different thresholds
as I registered them (such as playing with the parts-per-million
or even with virsh 'percentage sugar'):
# virsh -k0 domstats f20 --block | grep -C1 allo
block.0.write-threshold=10000
block.0.allocation=0
block.0.capacity=12884901888
In another window, I set up my event loop:
$ ./run tools/virsh -k0 event f20 --loop --all
then in the first window, I resumed things:
# virsh resume f20
and got this message in the second window, after several seconds
had elapsed (the first few seconds in the guest is under control
of Grub, which doesn't write to disk; when it transitioned over
to the Linux boot, disk activity started happening and easily
causes the qcow2 wrapper to exceed the threshold I set earlier):
$ ./run tools/virsh -k0 -c qemu:///system event --loop --all
event 'lifecycle' for domain f20: Resumed Unpaused
event 'lifecycle' for domain f20: Resumed Unpaused
event 'write-threshold' for domain f20 disk vda (/dev/sda6): threshold 10000 exceeded by 186608 bytes
Sure enough, the registration had cleared, and the qcow2 wrapper
had grown (it grew more than once in the process of booting, so
by the time I re-queried, allocation had grown even further).
# virsh -k0 domstats f20 --block | grep -C1 allo
block.0.write-threshold=0
block.0.allocation=13434368
block.0.capacity=12884901888
I'd really like to see this series in 1.3.0 to commit to the API;
there are still some further improvements we can make (in particular
'vda[1]' support, and also improving qemu event handling to re-grab
a job lock if the cache of node names is not populated after a
libvirtd restart), but as those improvements won't affect ABI, they
can be deferred if they don't make it into 1.3.0.
[I'm headed on vacation, so I will be really slow to respond in
the next 3 weeks; someone else may need to push this if it is
approved for 1.3.0]
Eric Blake (10):
threshold: new API virDomainBlockSetWriteThreshold
threshold: expose new API in virsh
threshold: new event object for tracking write threshold
threshold: wire up threshold event in RPC
threshold: add qemu capability bits
threshold: learn a node name for a given qcow2 disk
threshold: track an allocation node name for a storage source
threshold: scrape threshold data from QMP
threshold: add threshold event handling in qemu
threshold: add write threshold setting in qemu
daemon/remote.c | 51 +++
include/libvirt/libvirt-domain.h | 53 +++
src/conf/domain_event.c | 101 ++++-
src/conf/domain_event.h | 16 +-
src/driver-hypervisor.h | 7 +
src/libvirt-domain.c | 98 +++++
src/libvirt_private.syms | 2 +
src/libvirt_public.syms | 1 +
src/qemu/qemu_capabilities.c | 12 +-
src/qemu/qemu_capabilities.h | 4 +-
src/qemu/qemu_domain.c | 105 ++++++
src/qemu/qemu_domain.h | 10 +-
src/qemu/qemu_driver.c | 108 +++++-
src/qemu/qemu_migration.c | 2 +-
src/qemu/qemu_monitor.c | 79 +++-
src/qemu/qemu_monitor.h | 28 ++
src/qemu/qemu_monitor_json.c | 305 ++++++++++++++-
src/qemu/qemu_monitor_json.h | 11 +
src/qemu/qemu_process.c | 44 +++
src/remote/remote_driver.c | 35 ++
src/remote/remote_protocol.x | 30 +-
src/remote_protocol-structs | 16 +
src/util/virstoragefile.c | 4 +-
src/util/virstoragefile.h | 3 +-
tests/qemucapabilitiesdata/caps_2.1.1-1.replies | 470 ++++++++++++------------
tests/qemumonitortest.c | 13 +-
tools/virsh-domain-monitor.c | 108 ++++++
tools/virsh-domain.c | 24 ++
tools/virsh.pod | 26 ++
29 files changed, 1508 insertions(+), 258 deletions(-)
--
2.4.3
9 years, 5 months
[libvirt] [PATCH 0/2] Support for new watchdog model diag288 and action inject-nmi
by Boris Fiuczynski
This patche set provides support for the new watchdog model "diag288"
including the new watchdog action "inject-nmi".
Boris Fiuczynski (2):
Support for the new watchdog action inject-nmi
Support for the new watchdog model diag288
docs/formatdomain.html.in | 5 +++++
docs/schemas/domaincommon.rng | 2 ++
include/libvirt/libvirt-domain.h | 1 +
src/conf/domain_conf.c | 6 ++++--
src/conf/domain_conf.h | 2 ++
src/qemu/qemu_command.c | 6 +++---
src/qemu/qemu_monitor_json.c | 2 +-
tools/virsh-domain.c | 3 ++-
8 files changed, 20 insertions(+), 7 deletions(-)
--
2.3.0
9 years, 5 months
[libvirt] lxc: setsid() usage
by Richard Weinberger
Hi!
Why is libvirt-lxc issuing a setsid() in lxcContainerSetupFDs()?
To me it seems like a hack to have a controlling TTY if PID 1 is /bin/bash.
If one runs a sysv init style distro (like Debian) in libvirt-lxc the setsid() has
a major downside, when getty spawns a login shell on /dev/tty1 it cannot become
the controlling tty. Hence, if one presses ctrl-c in such a session, the container will
reboot.
Interestingly it does not happen when a systemd distro is used.
Maybe because systemd completely closes and reopens the TTY?
Thanks,
//richard
9 years, 5 months
[libvirt] [PATCH v2] nodeinfo: fix to parse present cpus rather than possible cpus
by Kothapally Madhu Pavan
Currently we are parsing all the possible cpus to get the
nodeinfo. This fix will perform a check for present cpus
before parsing.
Signed-off-by: Kothapally Madhu Pavan <kmp(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2fafe2d..0134aba 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -57,6 +57,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
VIR_LOG_INIT("nodeinfo");
+virBitmapPtr nodeGetPresentCPUBitmap(void);
#if defined(__FreeBSD__) || defined(__APPLE__)
static int
@@ -418,6 +419,7 @@ virNodeParseNode(const char *node,
int processors = 0;
DIR *cpudir = NULL;
struct dirent *cpudirent = NULL;
+ virBitmapPtr present_cpumap = NULL;
int sock_max = 0;
cpu_set_t sock_map;
int sock;
@@ -438,12 +440,18 @@ virNodeParseNode(const char *node,
goto cleanup;
}
+ present_cpumap = nodeGetPresentCPUBitmap();
+
/* enumerate sockets in the node */
CPU_ZERO(&sock_map);
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
+ if (present_cpumap)
+ if (!(virBitmapIsBitSet(present_cpumap, cpu)))
+ continue;
+
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
goto cleanup;
@@ -477,6 +485,10 @@ virNodeParseNode(const char *node,
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
+ if (present_cpumap)
+ if (!(virBitmapIsBitSet(present_cpumap, cpu)))
+ continue;
+
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
goto cleanup;
@@ -537,6 +549,7 @@ virNodeParseNode(const char *node,
ret = -1;
}
VIR_FREE(core_maps);
+ virBitmapFree(present_cpumap);
return ret;
}
9 years, 5 months
[libvirt] [PATCH 0/3] yajl cleanups
by Eric Blake
Fixes 'make check' on RHEL 6, which I recently broke, then adds
further improvements to the JSON parser.
I'm tempted to push patch 1/3 as a build-breaker, but since the
other two need review, I'll hold off and we can do all three as
a series.
Eric Blake (3):
json: cope with older yajl semantics
json: reject javascript comments
json: reject trailing garbage
src/util/virjson.c | 45 ++++++++++++++++++++++++++++++++++++++-------
tests/jsontest.c | 5 ++++-
2 files changed, 42 insertions(+), 8 deletions(-)
--
2.4.3
9 years, 5 months
[libvirt] bisected: Unable to get index for interface...
by Thomas Voegtle
Hi,
On my own build linux system without systemd, I have following problem,
when I try to start a qemu VM, libvirtd.log says:
2015-06-23 08:29:25.498+0000: 889: error : virNetDevGetIndex:842 : Unable
to get index for interface vm0.0: No such device
2015-06-23 08:29:25.551+0000: 886: error : virNetDevGetIndex:842 : Unable
to get index for interface vm0.0: No such device
2015-06-23 08:29:25.611+0000: 888: error : virNetDevGetIndex:842 : Unable
to get index for interface vm0.0: No such device
...
virsh dumpxml vm:
...
<interface type='ethernet'>
<mac address='52:54:00:cd:15:51'/>
<target dev='vm0.0'/>
<model type='virtio'/>
<boot order='3'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0f'
function='0x0'/>
</interface>
...
I had no problems with 1.2.12, so I started a git bisect and I came down
to this:
# first bad commit: [4bbe1029f2fb6cd1c102794951a944c62fdbd0e6] qemu: fix
ifindex array reported to systemd
When I revert that commit on top of 1.2.13.1, problem is gone.
I tried today's version (d10a5f58c75), problem is still in there.
Hope this is useful to you?
Thomas
9 years, 5 months
[libvirt] [PATCH] admin: Fix mingw build by reordering includes
by Martin Kletzander
By trying to lead the way of clean includes, I sorted the lines
alphabetically and that is a problem for mingw builds with gnulib.
As 'configmake.h' defines DATADIR and 'datatypes.h' transitively
includes 'winsock.h' that uses 'DATADIR' as a name for a struct,
it's enough to reorder those.
Even though this might be worked around in gnulib later on, this
fixes the build for now.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/libvirt-admin.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 11b6fe3238b8..b3fd0b3a8cf2 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -25,8 +25,9 @@
#include <rpc/rpc.h>
#include "internal.h"
-#include "configmake.h"
#include "datatypes.h"
+#include "configmake.h"
+
#include "viralloc.h"
#include "virlog.h"
#include "virnetclient.h"
--
2.4.4
9 years, 5 months