[libvirt] [PATCH] qemu: add PCI-multibus support for ppc
by Olivia Yin
Signed-off-by: Olivia Yin <hong-hua.yin(a)freescale.com>
---
src/qemu/qemu_capabilities.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7bc1ebc..7d7791d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2209,6 +2209,11 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid)
virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI);
}
+ /* ppc support PCI-multibus */
+ if (qemuCaps->arch == VIR_ARCH_PPC) {
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
+ }
+
/* virQEMUCapsExtractDeviceStr will only set additional caps if qemu
* understands the 0.13.0+ notion of "-device driver,". */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
@@ -2450,6 +2455,11 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
}
+ /* ppc support PCI-multibus */
+ if (qemuCaps->arch == VIR_ARCH_PPC) {
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
+ }
+
if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
goto cleanup;
if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0)
--
1.6.4
10 years, 8 months
[libvirt] [PATCH 0/4] Expose FSFreeze/FSThaw within the guest as commands
by Tomoki Sekiyama
Currently FSFreeze and FSThaw are supported by qemu guest agent and they are
used internally in snapshot-create command with --quiesce option.
However, when users want to utilize the native snapshot feature of storage
devices (such as LVM over iSCSI, various enterprise storage systems, etc.),
they need to issue fsfreeze command separately from libvirt-driven snapshots.
(OpenStack cinder provides these storages' snapshot feature, but it cannot
quiesce the guest filesystems automatically for now.)
Although virDomainQemuGuestAgent() API could be used for this purpose, it
depends too much on specific hypervisor implementation.
This patchset adds virDomainFSFreeze()/virDomainFSThaw() APIs and virsh
domfsfreeze/domfsthaw commands to enable the users to freeze and thaw
domain's filesystems cleanly.
The APIs has mountPoint and flags option currently unsupported for future
extension, as virDomainFSTrim() API.
Duplicated FSFreeze results in error caused by qemu guest agent.
---
Tomoki Sekiyama (4):
Introduce virDomainFSFreeze() public API
remote: Implement virDomainFSFreeze and virDomainFSThaw
qemu: Implement virDomainFSFreeze
virsh: Expose new virDomainFSFreeze and virDomainFSThaw API
include/libvirt/libvirt.h.in | 8 ++
src/access/viraccessperm.c | 2 -
src/access/viraccessperm.h | 6 ++
src/driver.h | 12 ++++
src/libvirt.c | 92 +++++++++++++++++++++++++++
src/libvirt_public.syms | 6 ++
src/qemu/qemu_driver.c | 142 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 2 +
src/remote/remote_protocol.x | 26 +++++++-
src/remote_protocol-structs | 12 ++++
src/rpc/gendispatch.pl | 2 +
tools/virsh-domain.c | 108 ++++++++++++++++++++++++++++++++
tools/virsh.pod | 17 +++++
13 files changed, 433 insertions(+), 2 deletions(-)
10 years, 8 months
[libvirt] [PATCH] Fix memory leak in virDomainSnapshotDiskDefClear()
by Nehal J Wani
While running domainsnapshotxml2xmltest, it was found that valgrind pointed out
the following memory leaks:
==32176== 42 (32 direct, 10 indirect) bytes in 1 blocks are definitely lost in loss record 42 of 66
==32176== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==32176== by 0x4A06B62: realloc (vg_replace_malloc.c:662)
==32176== by 0x4C65A07: virReallocN (viralloc.c:243)
==32176== by 0x4C65B2E: virExpandN (viralloc.c:292)
==32176== by 0x4C65E30: virInsertElementsN (viralloc.c:434)
==32176== by 0x4CD71F3: virDomainDiskSourceDefParse (domain_conf.c:5078)
==32176== by 0x4CF6EF4: virDomainSnapshotDefParseNode (snapshot_conf.c:151)
==32176== by 0x4CF7314: virDomainSnapshotDefParseString (snapshot_conf.c:410)
==32176== by 0x41FB8D: testCompareXMLToXMLHelper (domainsnapshotxml2xmltest.c:100)
==32176== by 0x420FD1: virtTestRun (testutils.c:199)
==32176== by 0x41F859: mymain (domainsnapshotxml2xmltest.c:222)
==32176== by 0x42174D: virtTestMain (testutils.c:782)
==32176==
==32176== 128 (96 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 51 of 66
==32176== at 0x4A06BE0: realloc (vg_replace_malloc.c:662)
==32176== by 0x4C65A07: virReallocN (viralloc.c:243)
==32176== by 0x4C65B2E: virExpandN (viralloc.c:292)
==32176== by 0x4C65E30: virInsertElementsN (viralloc.c:434)
==32176== by 0x4CD71F3: virDomainDiskSourceDefParse (domain_conf.c:5078)
==32176== by 0x4CF6EF4: virDomainSnapshotDefParseNode (snapshot_conf.c:151)
==32176== by 0x4CF7314: virDomainSnapshotDefParseString (snapshot_conf.c:410)
==32176== by 0x41FB8D: testCompareXMLToXMLHelper (domainsnapshotxml2xmltest.c:100)
==32176== by 0x420FD1: virtTestRun (testutils.c:199)
==32176== by 0x41F859: mymain (domainsnapshotxml2xmltest.c:222)
==32176== by 0x42174D: virtTestMain (testutils.c:782)
==32176== by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==32176==
---
src/conf/snapshot_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 12b0930..475525f 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -82,6 +82,7 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk)
{
VIR_FREE(disk->name);
VIR_FREE(disk->file);
+ virDomainDiskHostDefFree(disk->nhosts, disk->hosts);
}
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
--
1.7.1
10 years, 8 months
[libvirt] Libvirt Java Bindings - adding domain event support - pull request
by Chris Ellis
Hi all
I'm new to this list, I've been making use of the Libvirt Java bindings
recently. I wanted to make use of domain events yesterday
so my application can be alerted when the state of a domain changes etc.
However I quickly discovered that domain events are completely broken in
the current Java bindings. Whilst some of the Libvirt
functions required to support domain events are exposed, the critical
underpinnings are not. Specifically there is no support
for setting up the event loop.
So I have implemented support for domain events in the Java bindings.
Currently I've only implemented the following domain
event IDs:
* VIR_DOMAIN_EVENT_ID_LIFECYCLE
* VIR_DOMAIN_EVENT_ID_REBOOT
* VIR_DOMAIN_EVENT_ID_RTC_CHANGE
Implementing these is enough to test that my implementation is sane, I'm
hoping to implement the majority of the other events
soon.
Events can be listened to by, registering via the Connect object, as
follows:
con.domainEventRegisterAny(DomainEventID.VIR_DOMAIN_EVENT_ID_LIFECYCLE,
new DomainLifecycleEventHandler() {
@Override
public void onStarted(Connect connection, Domain domain, DomainEventType
event, DomainEventStartedDetailType detail) throws LibvirtException {
System.out.println("Got start event: " + event + "::" + detail + " for
domain " + domain.getName());
}
});
I've put my clone of the libvirt-java git repository on Github, my
modifications to the Java binding are in a separate branch and
should be simple to merge. The changes can be viewed at:
https://github.com/intrbiz/libvirt-java/compare/master...ce-domain-events
I'm keen to get these enhancements / fixes merged into libvirt-java. I
would also like to submit further fixes to race conditions
in the free() handling.
Any advice / thoughts / comments welcome.
Regards,
Chris Ellis
10 years, 8 months
Re: [libvirt] Compiling libvirt RPC client library for QNX
by Panday Ritesh Sharma (rpanday)
On 25/02/14 9:18 PM, "Panday Ritesh Sharma (rpanday)" <rpanday(a)cisco.com>
wrote:
>Hi Roman,
>Sorry !!! I did not understand "Once again, please don't top-post on
>technical lists."
>
>I should not include 'libvirt-list(a)redhat.com' in my mail thread ?
>
>I have already used the option '--without-libvirtd' and hence the result.
>
>We are using a wrapper of make for compilation for QNX. So I need to know,
>when I am compiling this client library on linux with '--without-libvirtd'
>option, what all .c files and libraries are being used. Then I will take
>those .c files to my build environment and link that to the libraries
>needed. I will have to see whether those libraries are present in my QNX
>build environment. Please helpŠ
>
>
>Regards
>Ritesh Sharma
>
>
>On 25/02/14 8:57 PM, "Eric Blake" <eblake(a)redhat.com> wrote:
>
>>On 02/25/2014 08:10 AM, Panday Ritesh Sharma (rpanday) wrote:
>>
>>Once again, please don't top-post on technical lists.
>>
>>> Hi Eric,
>>> I used the option '--without-macvtap' and I was able to compile on my
>>> linux box. When I compiled, I see many libraries are getting built. But
>>>as
>>> I have explained my requirement earlier, I just need a RPC client
>>>library,
>>> essentially the option '--with-remote'.
>>
>>To build just the client library, use ./configure --without-libvirtd.
>>
>>>
>>> If I check .c files I see only './src/libvirt.c' and './tools/virsh.c'
>>>are
>>> the two files where '# ifdef WITH_REMOTE' is present.
>>>
>>> Does it mean that as per my requirement I only need to compile these
>>>files?
>>
>>No. You must unpack the ENTIRE tarball, and then use the configure
>>options to control which files are built. Some of the logic on what to
>>build is in the makefiles, and another consideration is that there are a
>>LOT of library files that are used in both libvirt.so (your client
>>library) and in libvirtd (the daemon executable that you are not
>>building).
>>
>>>
>>> My intent is to have a library with minimal files which suffice to my
>>> requirement. Because that way it will be easier for me to compile them
>>>on
>>> QNX.
>>
>>Using configure options to compile fewer files is reasonable. Omitting
>>files from the tarball is not.
>>
>>>
>>> You have mentioned on another thread that in a weeks time some new
>>>version
>>> of libvirt will come which we can compile for non-linux machines ? What
>>> change is coming in that version ? The latest version of libvirt can
>>>not
>>> be compiled for QNX ?
>>
>>The latest version is currently 1.2.1, but 1.2.2-rc0 was just announced
>>and 1.2.2 is expected next week if all goes well. If you could test
>>1.2.2-rc0 on QNX, we can still fix issues that you turn up before 1.2.2
>>goes stable.
>>
>>
>>--
>>Eric Blake eblake redhat com +1-919-301-3266
>>Libvirt virtualization library http://libvirt.org
Adding [libvirt-list]
Hi Eric,
This time I am writing a the bottom of this thread, is this correct ?
Write way of mailing ? Could you please reply my query ?
Regards
Ritesh Sharma
>>
>
10 years, 8 months
[libvirt] [PATCHv2 0/2] Add virusbtest
by Ján Tomko
v1: https://www.redhat.com/archives/libvir-list/2014-February/msg01620.html
v2:
Split the mocked part into a separate file and only build the test on Linux.
Remove 'serial' files.
Get out of testDeviceFind earlier if failure is expected and use a switch.
Switches are nice.
Check number of returned devices more often in testUSBList,
not just at the end.
Ján Tomko (2):
Add tests for virUSBDeviceFind functions
Add a test for virUSBDeviceList functions
.gitignore | 1 +
cfg.mk | 3 +-
tests/Makefile.am | 22 ++
tests/virusbmock.c | 99 +++++++
tests/virusbtest.c | 292 +++++++++++++++++++++
.../sys_bus_usb/devices/1-1.5.3.1/devnum | 1 +
.../sys_bus_usb/devices/1-1.5.3.1/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5.3.1/idVendor | 1 +
.../sys_bus_usb/devices/1-1.5.3.3/devnum | 1 +
.../sys_bus_usb/devices/1-1.5.3.3/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5.3.3/idVendor | 1 +
.../sys_bus_usb/devices/1-1.5.3/devnum | 1 +
.../sys_bus_usb/devices/1-1.5.3/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5.3/idVendor | 1 +
.../sys_bus_usb/devices/1-1.5.4/devnum | 1 +
.../sys_bus_usb/devices/1-1.5.4/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5.4/idVendor | 1 +
.../sys_bus_usb/devices/1-1.5.5/devnum | 1 +
.../sys_bus_usb/devices/1-1.5.5/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5.5/idVendor | 1 +
.../sys_bus_usb/devices/1-1.5.6/devnum | 1 +
.../sys_bus_usb/devices/1-1.5.6/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5.6/idVendor | 1 +
.../sys_bus_usb/devices/1-1.5/devnum | 1 +
.../sys_bus_usb/devices/1-1.5/idProduct | 1 +
.../sys_bus_usb/devices/1-1.5/idVendor | 1 +
.../sys_bus_usb/devices/1-1.6/devnum | 1 +
.../sys_bus_usb/devices/1-1.6/idProduct | 1 +
.../sys_bus_usb/devices/1-1.6/idVendor | 1 +
.../virusbtestdata/sys_bus_usb/devices/1-1/devnum | 1 +
.../sys_bus_usb/devices/1-1/idProduct | 1 +
.../sys_bus_usb/devices/1-1/idVendor | 1 +
.../sys_bus_usb/devices/2-1.2/devnum | 1 +
.../sys_bus_usb/devices/2-1.2/idProduct | 1 +
.../sys_bus_usb/devices/2-1.2/idVendor | 1 +
.../virusbtestdata/sys_bus_usb/devices/2-1/devnum | 1 +
.../sys_bus_usb/devices/2-1/idProduct | 1 +
.../sys_bus_usb/devices/2-1/idVendor | 1 +
.../virusbtestdata/sys_bus_usb/devices/usb1/devnum | 1 +
.../sys_bus_usb/devices/usb1/idProduct | 1 +
.../sys_bus_usb/devices/usb1/idVendor | 1 +
.../virusbtestdata/sys_bus_usb/devices/usb2/devnum | 1 +
.../sys_bus_usb/devices/usb2/idProduct | 1 +
.../sys_bus_usb/devices/usb2/idVendor | 1 +
.../virusbtestdata/sys_bus_usb/devices/usb3/devnum | 1 +
.../sys_bus_usb/devices/usb3/idProduct | 1 +
.../sys_bus_usb/devices/usb3/idVendor | 1 +
.../virusbtestdata/sys_bus_usb/devices/usb4/devnum | 1 +
.../sys_bus_usb/devices/usb4/idProduct | 1 +
.../sys_bus_usb/devices/usb4/idVendor | 1 +
50 files changed, 461 insertions(+), 1 deletion(-)
create mode 100644 tests/virusbmock.c
create mode 100644 tests/virusbtest.c
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.1/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.1/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.1/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.3/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.3/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3.3/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.3/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.4/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.4/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.4/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.5/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.5/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.5/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.6/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.6/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5.6/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.5/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.6/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.6/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1.6/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/1-1/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1.2/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1.2/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1.2/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/2-1/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb1/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb1/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb1/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb2/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb2/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb2/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb3/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb3/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb3/idVendor
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb4/devnum
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb4/idProduct
create mode 100644 tests/virusbtestdata/sys_bus_usb/devices/usb4/idVendor
--
1.8.3.2
10 years, 8 months
[libvirt] [PATCH] Check if systemd is the init before creating machines
by Ján Tomko
If systemd is installed, but not the init system,
systemd-machined fails with an unhelpful error message:
Launch helper exited with unknown return code 1
Fall back to manual cgroup creation if systemd is installed,
but it's not PID 1.
[1] https://bugs.freedesktop.org/show_bug.cgi?id=69962
---
(Yes, Gentoo.)
src/util/virsystemd.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 8adf209..0404a63 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -30,6 +30,7 @@
#include "virstring.h"
#include "viralloc.h"
#include "virutil.h"
+#include "virfile.h"
#include "virlog.h"
#include "virerror.h"
@@ -142,6 +143,28 @@ cleanup:
return machinename;
}
+/*
+ * Returns 0 if systemd is the init, -2 if not
+ * -1 on fatal error
+ */
+static int
+virSystemdIsInit(void)
+{
+ char *buf = NULL;
+ int ret = -2;
+
+ if (virFileReadAll("/proc/1/comm", sizeof("systemd\n "), &buf) < 0)
+ return -1;
+
+ if (STREQ(buf, "systemd\n"))
+ ret = 0;
+ else
+ VIR_DEBUG("systemd is not the init");
+
+ VIR_FREE(buf);
+ return ret;
+}
+
/**
* virSystemdCreateMachine:
* @name: driver unique name of the machine
@@ -173,6 +196,9 @@ int virSystemdCreateMachine(const char *name,
if (ret < 0)
return ret;
+ if ((ret = virSystemdIsInit()) < 0)
+ return ret;
+
if (!(conn = virDBusGetSystemBus()))
return -1;
--
1.8.3.2
10 years, 8 months
[libvirt] [PATCH] virsh: support remaining domain events
by Eric Blake
Earlier, I added 'virsh event' for lifecycle events, to get the
concept approved; this patch finishes the support for all other
events, although the user still has to register for one event
type at a time. A future patch may add an --all parameter to
make it possible to register for all events through a single
call.
* tools/virsh-domain.c (vshDomainEventWatchdogToString)
(vshDomainEventIOErrorToString, vshGraphicsPhaseToString)
(vshGraphicsAddressToString, vshDomainBlockJobStatusToString)
(vshDomainEventDiskChangeToString)
(vshDomainEventTrayChangeToString, vshEventGenericPrint)
(vshEventRTCChangePrint, vshEventWatchdogPrint)
(vshEventIOErrorPrint, vshEventGraphicsPrint)
(vshEventIOErrorReasonPrint, vshEventBlockJobPrint)
(vshEventDiskChangePrint, vshEventTrayChangePrint)
(vshEventPMChangePrint, vshEventBalloonChangePrint)
(vshEventDeviceRemovedPrint): New helper routines.
(cmdEvent): Support full array of event callbacks.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
tools/virsh-domain.c | 392 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 381 insertions(+), 11 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 8e42300..3cffc9c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10434,18 +10434,135 @@ vshDomainEventDetailToString(int event, int detail)
return str ? _(str) : _("unknown");
}
+VIR_ENUM_DECL(vshDomainEventWatchdog)
+VIR_ENUM_IMPL(vshDomainEventWatchdog,
+ VIR_DOMAIN_EVENT_WATCHDOG_LAST,
+ N_("none"),
+ N_("pause"),
+ N_("reset"),
+ N_("poweroff"),
+ N_("shutdown"),
+ N_("debug"))
+
+static const char *
+vshDomainEventWatchdogToString(int action)
+{
+ const char *str = vshDomainEventWatchdogTypeToString(action);
+ return str ? _(str) : _("unknown");
+}
+
+VIR_ENUM_DECL(vshDomainEventIOError)
+VIR_ENUM_IMPL(vshDomainEventIOError,
+ VIR_DOMAIN_EVENT_IO_ERROR_LAST,
+ N_("none"),
+ N_("pause"),
+ N_("report"))
+
+static const char *
+vshDomainEventIOErrorToString(int action)
+{
+ const char *str = vshDomainEventIOErrorTypeToString(action);
+ return str ? _(str) : _("unknown");
+}
+
+VIR_ENUM_DECL(vshGraphicsPhase)
+VIR_ENUM_IMPL(vshGraphicsPhase,
+ VIR_DOMAIN_EVENT_GRAPHICS_LAST,
+ N_("connect"),
+ N_("initialize"),
+ N_("disconnect"))
+
+static const char *
+vshGraphicsPhaseToString(int phase)
+{
+ const char *str = vshGraphicsPhaseTypeToString(phase);
+ return str ? _(str) : _("unknown");
+}
+
+VIR_ENUM_DECL(vshGraphicsAddress)
+VIR_ENUM_IMPL(vshGraphicsAddress,
+ VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_LAST,
+ N_("IPv4"),
+ N_("IPv6"),
+ N_("unix"))
+
+static const char *
+vshGraphicsAddressToString(int family)
+{
+ const char *str = vshGraphicsAddressTypeToString(family);
+ return str ? _(str) : _("unknown");
+}
+
+VIR_ENUM_DECL(vshDomainBlockJobStatus)
+VIR_ENUM_IMPL(vshDomainBlockJobStatus,
+ VIR_DOMAIN_BLOCK_JOB_LAST,
+ N_("completed"),
+ N_("failed"),
+ N_("canceled"),
+ N_("ready"))
+
+static const char *
+vshDomainBlockJobStatusToString(int status)
+{
+ const char *str = vshDomainBlockJobStatusTypeToString(status);
+ return str ? _(str) : _("unknown");
+}
+
+VIR_ENUM_DECL(vshDomainEventDiskChange)
+VIR_ENUM_IMPL(vshDomainEventDiskChange,
+ VIR_DOMAIN_EVENT_DISK_CHANGE_LAST,
+ N_("changed"),
+ N_("dropped"))
+
+static const char *
+vshDomainEventDiskChangeToString(int reason)
+{
+ const char *str = vshDomainEventDiskChangeTypeToString(reason);
+ return str ? _(str) : _("unknown");
+}
+
+VIR_ENUM_DECL(vshDomainEventTrayChange)
+VIR_ENUM_IMPL(vshDomainEventTrayChange,
+ VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST,
+ N_("opened"),
+ N_("closed"))
+
+static const char *
+vshDomainEventTrayChangeToString(int reason)
+{
+ const char *str = vshDomainEventTrayChangeTypeToString(reason);
+ return str ? _(str) : _("unknown");
+}
+
+struct vshEventCallback {
+ const char *name;
+ virConnectDomainEventGenericCallback cb;
+};
+typedef struct vshEventCallback vshEventCallback;
+
struct vshDomEventData {
vshControl *ctl;
bool loop;
int count;
+ vshEventCallback *cb;
};
typedef struct vshDomEventData vshDomEventData;
-/* FIXME: Support all callbacks, not just lifecycle */
-VIR_ENUM_DECL(vshDomainEventId)
-VIR_ENUM_IMPL(vshDomainEventId,
- /* VIR_DOMAIN_EVENT_ID_LAST, */ 1,
- "lifecycle")
+static void
+vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event '%s' for domain %s\n"),
+ data->cb->name, virDomainGetName(dom));
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
static void
vshEventLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -10466,6 +10583,257 @@ vshEventLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
vshEventDone(data->ctl);
}
+static void
+vshEventRTCChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ long long utcoffset,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event 'rtc-change' for domain %s: %lld\n"),
+ virDomainGetName(dom), utcoffset);
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventWatchdogPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ int action,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event 'watchdog' for domain %s: %s\n"),
+ virDomainGetName(dom), vshDomainEventWatchdogToString(action));
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventIOErrorPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *srcPath,
+ const char *devAlias,
+ int action,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event 'io-error' for domain %s: %s (%s) %s\n"),
+ virDomainGetName(dom), srcPath, devAlias,
+ vshDomainEventIOErrorToString(action));
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventGraphicsPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ int phase,
+ const virDomainEventGraphicsAddress *local,
+ const virDomainEventGraphicsAddress *remote,
+ const char *authScheme,
+ const virDomainEventGraphicsSubject *subject,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+ size_t i;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event 'graphics' for domain %s: "
+ "%s local[%s %s %s] remote[%s %s %s] %s"),
+ virDomainGetName(dom), vshGraphicsPhaseToString(phase),
+ vshGraphicsAddressToString(local->family),
+ local->node, local->service,
+ vshGraphicsAddressToString(remote->family),
+ remote->node, remote->service,
+ authScheme);
+ for (i = 0; i < subject->nidentity; i++)
+ vshPrint(data->ctl, " %s=%s", subject->identities[i].type,
+ subject->identities[i].name);
+ vshPrint(data->ctl, "\n");
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventIOErrorReasonPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *srcPath,
+ const char *devAlias,
+ int action,
+ const char *reason,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event 'io-error-reason' for domain %s: "
+ "%s (%s) %s due to %s\n"),
+ virDomainGetName(dom), srcPath, devAlias,
+ vshDomainEventIOErrorToString(action), reason);
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventBlockJobPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *disk,
+ int type,
+ int status,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl, _("event 'block-job' for domain %s: %s for %s %s\n"),
+ virDomainGetName(dom), vshDomainBlockJobToString(type),
+ disk, vshDomainBlockJobStatusToString(status));
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventDiskChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *oldSrc,
+ const char *newSrc,
+ const char *alias,
+ int reason,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl,
+ _("event 'disk-change' for domain %s disk %s: %s -> %s: %s\n"),
+ virDomainGetName(dom), alias, NULLSTR(oldSrc), NULLSTR(newSrc),
+ vshDomainEventDiskChangeToString(reason));
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventTrayChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *alias,
+ int reason,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl,
+ _("event 'disk-change' for domain %s disk %s: %s\n"),
+ virDomainGetName(dom), alias,
+ vshDomainEventTrayChangeToString(reason));
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventPMChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ int reason ATTRIBUTE_UNUSED,
+ void *opaque)
+{
+ /* As long as libvirt.h doesn't define any reasons, we might as
+ * well treat all PM state changes as generic events. */
+ vshEventGenericPrint(conn, dom, opaque);
+}
+
+static void
+vshEventBalloonChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ unsigned long long actual,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl,
+ _("event 'balloon-change' for domain %s: %lluKiB\n"),
+ virDomainGetName(dom), actual);
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static void
+vshEventDeviceRemovedPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ const char *alias,
+ void *opaque)
+{
+ vshDomEventData *data = opaque;
+
+ if (!data->loop && data->count)
+ return;
+ vshPrint(data->ctl,
+ _("event 'device-removed' for domain %s: %s\n"),
+ virDomainGetName(dom), alias);
+ data->count++;
+ if (!data->loop)
+ vshEventDone(data->ctl);
+}
+
+static vshEventCallback vshEventCallbacks[] = {
+ { "lifecycle",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventLifecyclePrint), },
+ { "reboot", vshEventGenericPrint, },
+ { "rtc-change",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventRTCChangePrint), },
+ { "watchdog",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventWatchdogPrint), },
+ { "io-error",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventIOErrorPrint), },
+ { "graphics",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventGraphicsPrint), },
+ { "io-error-reason",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventIOErrorReasonPrint), },
+ { "control-error", vshEventGenericPrint, },
+ { "block-job",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventBlockJobPrint), },
+ { "disk-change",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventDiskChangePrint), },
+ { "tray-change",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventTrayChangePrint), },
+ { "pm-wakeup",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventPMChangePrint), },
+ { "pm-suspend",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventPMChangePrint), },
+ { "balloon-change",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventBalloonChangePrint), },
+ { "pm-suspend-disk",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventPMChangePrint), },
+ { "device-removed",
+ VIR_DOMAIN_EVENT_CALLBACK(vshEventDeviceRemovedPrint), },
+};
+verify(VIR_DOMAIN_EVENT_ID_LAST == ARRAY_CARDINALITY(vshEventCallbacks));
+
static const vshCmdInfo info_event[] = {
{.name = "event",
.data = N_("Domain Events")
@@ -10512,10 +10880,8 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
int event;
if (vshCommandOptBool(cmd, "list")) {
- size_t i;
-
- for (i = 0; i < 1 /* VIR_DOMAIN_EVENT_ID_LAST */; i++)
- vshPrint(ctl, "%s\n", vshDomainEventIdTypeToString(i));
+ for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
+ vshPrint(ctl, "%s\n", vshEventCallbacks[event].name);
return true;
}
@@ -10525,7 +10891,10 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, "%s", _("either --list or event type is required"));
return false;
}
- if ((event = vshDomainEventIdTypeFromString(eventName) < 0)) {
+ for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
+ if (STREQ(eventName, vshEventCallbacks[event].name))
+ break;
+ if (event == VIR_DOMAIN_EVENT_ID_LAST) {
vshError(ctl, _("unknown event type %s"), eventName);
return false;
}
@@ -10533,6 +10902,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
data.ctl = ctl;
data.loop = vshCommandOptBool(cmd, "loop");
data.count = 0;
+ data.cb = &vshEventCallbacks[event];
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
return false;
@@ -10542,7 +10912,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
if ((eventId = virConnectDomainEventRegisterAny(ctl->conn, dom, event,
- VIR_DOMAIN_EVENT_CALLBACK(vshEventLifecyclePrint),
+ data.cb->cb,
&data, NULL)) < 0)
goto cleanup;
switch (vshEventWait(ctl)) {
--
1.8.5.3
10 years, 9 months
[libvirt] KVM Domain memory and disk usage
by Qiang Fu
Hi all,
I am trying to use virsh to get the memory and storage usage for KVM domain.
Right now we can get domain memory statistics through the following virsh
cmds:
1. dumpxml: this returns "memory" and "currentMemory"
2. dominfo: this returns "Max memory" and "Used memory"
3. dommemstat: this returns "actual" and "rss"
We think "memory" (from dumpxml) = "Max memory" (from dominfo) and
"currentMemory" (from dumpxml) = "Used memory" (from dominfo). Can anyone
please help us to confirm this?
We don't understand what does "actual" stand for in dommemstat. Can anyone
please explain us about that?
Finally, we want to get the memory utilization of the domain on VM level in
percentage. And we derive it as:
Utilization = rss / Used memory
Can anyone please provide any comment on this?
In terms of disk usage, it seems virsh / libvirt does not support any
domain disk information right now. If not, can anyone please give us any
idea how to get the domain disk information (size, used space and so on)?
Thanks a lot,
Bruce
10 years, 9 months
[libvirt] [PATCH] bhyve: support domain undefine
by Roman Bogorodskiy
Re-add domain undefine support. I have already implemented it in v9
of my initial bhyve patch, but, apparently, based v10 not on v9, but on v8,
so this change didn't make it into the tree (shame on me).
Roman Bogorodskiy (1):
bhyve: support domain undefine
src/bhyve/bhyve_driver.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
src/bhyve/bhyve_utils.h | 1 +
2 files changed, 80 insertions(+)
--
1.8.4.2
10 years, 9 months