[libvirt] [PATCH] qemu: driver: Allow passing disk target as top image with block commit
by Peter Krempa
Since we allow active layer block commit the users are allowed to commit
the top of the chain (e.g. vda) into the backing image. The API would
not accept that parameter, as it tried to look up the image in the
backing chain.
Add the ability to use the top level image target name explicitly as the
top image of the block commit operation.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1451394
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1c4873e48..36d8a701a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16942,7 +16942,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (qemuDomainDiskBlockJobIsActive(disk))
goto endjob;
- if (!top)
+ if (!top || STREQ(top, disk->dst))
topSource = disk->src;
else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 ||
!(topSource = virStorageFileChainLookup(disk->src, NULL,
--
2.12.2
7 years, 6 months
Re: [libvirt] [PATCH v3 08/31] Introduce virStreamSparseRecvAll
by Michal Privoznik
On 05/16/2017 11:34 PM, John Ferlan wrote:
>
>
> On 05/16/2017 10:03 AM, Michal Privoznik wrote:
>> This is just a wrapper over new functions that have been just
>> introduced: virStreamRecvFlags(), virStreamRecvHole(). It's very
>> similar to virStreamRecvAll() except it handles sparse streams
>> well.
>>
>> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
>> ---
>> include/libvirt/libvirt-stream.h | 33 ++++++++++-
>> src/libvirt-stream.c | 123 +++++++++++++++++++++++++++++++++++++++
>> src/libvirt_public.syms | 1 +
>> 3 files changed, 154 insertions(+), 3 deletions(-)
>>
>
> [...]
>
>> diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
>> index bedb6159a..6bf4c4f29 100644
>> --- a/src/libvirt-stream.c
>> +++ b/src/libvirt-stream.c
>> @@ -668,6 +668,129 @@ virStreamRecvAll(virStreamPtr stream,
>> }
>>
>>
>> +/**
>> + * virStreamSparseRecvAll:
>> + * @stream: pointer to the stream object
>> + * @handler: sink callback for writing data to application
>> + * @holeHandler: stream hole callback for skipping holes
>> + * @opaque: application defined data
>> + *
>> + * Receive the entire data stream, sending the data to the
>> + * requested data sink @handler and calling the skip @holeHandler
>> + * to generate holes for sparse stream targets. This is simply a
>> + * convenient alternative to virStreamRecvFlags, for apps that do
>> + * blocking-I/O.
>> + *
>> + * An example using this with a hypothetical file download
>> + * API looks like:
>> + *
>> + * int mysink(virStreamPtr st, const char *buf, int nbytes, void *opaque) {
>> + * int *fd = opaque;
>> + *
>> + * return write(*fd, buf, nbytes);
>> + * }
>> + *
>> + * int myskip(virStreamPtr st, long long offset, void *opaque) {
>> + * int *fd = opaque;
>> + *
>
> I think this is where perhaps the example of lseek in "off_t" chunks of
> "long long offset" would be applicable... Perhaps why I ended up in the
> off_t rathole before.
Not sure what you mean. long long is the same size as off_t for any
application that enables large file support (libvirt does that) or is
compiled on 64bits. Any 32bit virt mgmt application should really enable
large file support, otherwise is pretty useless.
>
>> + * return lseek(*fd, offset, SEEK_CUR) == (off_t) -1 ? -1 : 0;
>> + * }
>> + *
>> + * virStreamPtr st = virStreamNew(conn, 0);
>> + * int fd = open("demo.iso", O_WRONLY);
>> + *
>> + * virConnectDownloadSparseFile(conn, st);
>
> ^^ This API doesn't exist... Of course neither did
> virConnectDownloadFile from whence you copied the example. Maybe both
> should be 'adjusted'.
Maybe. One day. For now I'm happy with this example as-is. The example
should show how to set up virStreamSparseRecvAll.
Michal
7 years, 6 months
[libvirt] [PATCH python] Fix virStream.sendAll for Python 3
by Xavier Fernandez
In Python 3, if the file is open in binary mode, ``got`` will end up
being equal to b"" and b"" != "" in Python 3.
---
libvirt-override-virStream.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py
index c328154..2e77cc7 100644
--- a/libvirt-override-virStream.py
+++ b/libvirt-override-virStream.py
@@ -83,7 +83,7 @@
pass
raise e
- if got == "":
+ if not got:
break
ret = self.send(got)
--
2.12.2
7 years, 6 months
[libvirt] [PATCH 0/1] Enable Travis build status icon
by Claudio André
Follow up of the recent 'work in progress' announced in "Enable CI build testing with Travis" mailing message.
Claudio André (1):
Enable Travis CI build status icon
README.md | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 README.md
--
2.11.0
7 years, 6 months
Re: [libvirt] [PATCH v3 08/31] Introduce virStreamSparseRecvAll
by John Ferlan
I was wondering why this never made it to the list - seems I just sent
it to Michal... So here's what I sent...
John
On 05/16/2017 05:34 PM, John Ferlan wrote:
>
>
> On 05/16/2017 10:03 AM, Michal Privoznik wrote:
>> This is just a wrapper over new functions that have been just
>> introduced: virStreamRecvFlags(), virStreamRecvHole(). It's very
>> similar to virStreamRecvAll() except it handles sparse streams
>> well.
>>
>> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
>> ---
>> include/libvirt/libvirt-stream.h | 33 ++++++++++-
>> src/libvirt-stream.c | 123 +++++++++++++++++++++++++++++++++++++++
>> src/libvirt_public.syms | 1 +
>> 3 files changed, 154 insertions(+), 3 deletions(-)
>>
>
> [...]
>
>> diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
>> index bedb6159a..6bf4c4f29 100644
>> --- a/src/libvirt-stream.c
>> +++ b/src/libvirt-stream.c
>> @@ -668,6 +668,129 @@ virStreamRecvAll(virStreamPtr stream,
>> }
>>
>>
>> +/**
>> + * virStreamSparseRecvAll:
>> + * @stream: pointer to the stream object
>> + * @handler: sink callback for writing data to application
>> + * @holeHandler: stream hole callback for skipping holes
>> + * @opaque: application defined data
>> + *
>> + * Receive the entire data stream, sending the data to the
>> + * requested data sink @handler and calling the skip @holeHandler
>> + * to generate holes for sparse stream targets. This is simply a
>> + * convenient alternative to virStreamRecvFlags, for apps that do
>> + * blocking-I/O.
>> + *
>> + * An example using this with a hypothetical file download
>> + * API looks like:
>> + *
>> + * int mysink(virStreamPtr st, const char *buf, int nbytes, void *opaque) {
>> + * int *fd = opaque;
>> + *
>> + * return write(*fd, buf, nbytes);
>> + * }
>> + *
>> + * int myskip(virStreamPtr st, long long offset, void *opaque) {
>> + * int *fd = opaque;
>> + *
>
> I think this is where perhaps the example of lseek in "off_t" chunks of
> "long long offset" would be applicable... Perhaps why I ended up in the
> off_t rathole before.
>
>> + * return lseek(*fd, offset, SEEK_CUR) == (off_t) -1 ? -1 : 0;
>> + * }
>> + *
>> + * virStreamPtr st = virStreamNew(conn, 0);
>> + * int fd = open("demo.iso", O_WRONLY);
>> + *
>> + * virConnectDownloadSparseFile(conn, st);
>
> ^^ This API doesn't exist... Of course neither did
> virConnectDownloadFile from whence you copied the example. Maybe both
> should be 'adjusted'.
>
>
> Reviewed-by: John Ferlan <jferlan(a)redhat.com>
>
> John
>
>> + * if (virStreamSparseRecvAll(st, mysink, myskip, &fd) < 0) {
>> + * ...report an error ...
>> + * goto done;
>> + * }
>> + * if (virStreamFinish(st) < 0)
>> + * ...report an error...
>> + * virStreamFree(st);
>> + * close(fd);
>> + *
>> + * Note that @opaque data is shared between both @handler and
>> + * @holeHandler callbacks.
>> + *
>> + * Returns 0 if all the data was successfully received. The caller
>> + * should invoke virStreamFinish(st) to flush the stream upon
>> + * success and then virStreamFree(st).
>> + *
>> + * Returns -1 upon any error, with virStreamAbort() already
>> + * having been called, so the caller need only call virStreamFree().
>> + */
>
>
> [...]
>
7 years, 6 months
[libvirt] set link state for ethernet network devices
by Vasiliy Tolstov
Hi! Sometimes ago i'm write patch for setting link state of network
interface for ethernet type (tap).
Now i'm try libvirt 3.3.0 and see, that tap interfaces is up but in
xml i'm try to specify
<link state='down'>
also i'm try
<source><link state='down'></source>
Nothing changed. Laine says, that link state is only for internal
representation, and to modify link state on host side i need to
specify <source><link state='down'></source>.
For history please check email thread "qemu: remove unnecessary
setting of tap device online state"
So does this bug or it my mistake?
Thanks!
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
7 years, 6 months
[libvirt] [PATCH v3] qemu: Report shutdown event details
by Martin Kletzander
QEMU will likely report the details of it shutting down, particularly
whether the shutdown was initiated by the guest or host. We should
forward that information along, at least for shutdown events. Reset
has that as well, however that is not a lifecycle event and would add
extra constants that might not be used. It can be added later on.
Since the only way we can extend information provided to the user is
adding event details, we might as well emit multiple events (one with
the reason for the shutdown and keep the one for the shutdown being
finished for clarity and compatibility).
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1384007
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v3:
- don't send two events, just change the detail for the existing one
v2:
- adapt to newer patches
This is not in qemu master yet; if ACKed it will not be pushed before
the appropriate patches hit qemu master.
examples/object-events/event-test.c | 6 ++++++
include/libvirt/libvirt-domain.h | 11 ++++++++++-
src/qemu/qemu_monitor.c | 6 +++---
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 10 ++++++++--
src/qemu/qemu_process.c | 21 +++++++++++++++++++--
tools/virsh-domain.c | 4 +++-
7 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 12690cac09ce..78d200806601 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -240,6 +240,12 @@ eventDetailToString(int event,
case VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED:
return "Finished";
+ case VIR_DOMAIN_EVENT_SHUTDOWN_GUEST:
+ return "Guest request";
+
+ case VIR_DOMAIN_EVENT_SHUTDOWN_HOST:
+ return "Host request";
+
case VIR_DOMAIN_EVENT_SHUTDOWN_LAST:
break;
}
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index c9e96a6c90bc..720db32f7663 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2983,7 +2983,16 @@ typedef enum {
* Details on the cause of a 'shutdown' lifecycle event
*/
typedef enum {
- VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0, /* Guest finished shutdown sequence */
+ /* Guest finished shutdown sequence */
+ VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0,
+
+ /* Domain finished shutting down after request from the guest itself
+ * (e.g. hardware-specific action) */
+ VIR_DOMAIN_EVENT_SHUTDOWN_GUEST = 1,
+
+ /* Domain finished shutting down after request from the host (e.g. killed by
+ * a signal) */
+ VIR_DOMAIN_EVENT_SHUTDOWN_HOST = 2,
# ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_EVENT_SHUTDOWN_LAST
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2148d483ed6a..a2de1a6c5bad 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1326,13 +1326,13 @@ qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
int
-qemuMonitorEmitShutdown(qemuMonitorPtr mon)
+qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest)
{
int ret = -1;
- VIR_DEBUG("mon=%p", mon);
+ VIR_DEBUG("mon=%p guest=%u", mon, guest);
mon->willhangup = 1;
- QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm);
+ QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm, guest);
return ret;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 12f98beba763..8956bf929aaa 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -130,6 +130,7 @@ typedef int (*qemuMonitorDomainEventCallback)(qemuMonitorPtr mon,
void *opaque);
typedef int (*qemuMonitorDomainShutdownCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
+ virTristateBool guest,
void *opaque);
typedef int (*qemuMonitorDomainResetCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
@@ -344,7 +345,7 @@ int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
long long seconds, unsigned int micros,
const char *details);
-int qemuMonitorEmitShutdown(qemuMonitorPtr mon);
+int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 083729003ba3..757595dd7472 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -523,9 +523,15 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
}
-static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
+static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data)
{
- qemuMonitorEmitShutdown(mon);
+ bool guest = false;
+ virTristateBool guest_initiated = VIR_TRISTATE_BOOL_ABSENT;
+
+ if (virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
+ guest_initiated = guest ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
+
+ qemuMonitorEmitShutdown(mon, guest_initiated);
}
static void qemuMonitorJSONHandleReset(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c19bd292596a..e9c4e38abfb2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -634,12 +634,14 @@ qemuProcessHandleEvent(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
static int
qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
+ virTristateBool guest_initiated,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
qemuDomainObjPrivatePtr priv;
virObjectEventPtr event = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ int detail = 0;
VIR_DEBUG("vm=%p", vm);
@@ -662,9 +664,24 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjSetState(vm,
VIR_DOMAIN_SHUTDOWN,
VIR_DOMAIN_SHUTDOWN_UNKNOWN);
+
+ switch (guest_initiated) {
+ case VIR_TRISTATE_BOOL_YES:
+ detail = VIR_DOMAIN_EVENT_SHUTDOWN_GUEST;
+ break;
+
+ case VIR_TRISTATE_BOOL_NO:
+ detail = VIR_DOMAIN_EVENT_SHUTDOWN_HOST;
+ break;
+
+ default:
+ detail = VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED;
+ break;
+ }
+
event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_SHUTDOWN,
- VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED);
+ VIR_DOMAIN_EVENT_SHUTDOWN,
+ detail);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) {
VIR_WARN("Unable to save status on vm %s after state change",
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0d19d0e0126e..0e5d8e3c242c 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -12249,7 +12249,9 @@ VIR_ENUM_IMPL(virshDomainEventStopped,
VIR_ENUM_DECL(virshDomainEventShutdown)
VIR_ENUM_IMPL(virshDomainEventShutdown,
VIR_DOMAIN_EVENT_SHUTDOWN_LAST,
- N_("Finished"))
+ N_("Finished"),
+ N_("Finished after guest request"),
+ N_("Finished after host request"))
VIR_ENUM_DECL(virshDomainEventPMSuspended)
VIR_ENUM_IMPL(virshDomainEventPMSuspended,
--
2.13.0
7 years, 6 months
[libvirt] [PATCH v2] qemu: Report shutdown event details
by Martin Kletzander
QEMU will likely report the details of it shutting down, particularly
whether the shutdown was initiated by the guest or host. We should
forward that information along, at least for shutdown events. Reset
has that as well, however that is not a lifecycle event and would add
extra constants that might not be used. It can be added later on.
Since the only way we can extend information provided to the user is
adding event details, we might as well emit multiple events (one with
the reason for the shutdown and keep the one for the shutdown being
finished for clarity and compatibility).
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1384007
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v2:
- Adapt to new message format
Patch in QEMU: https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg03624.html
Applied to qapi-next: https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg03742.html
examples/object-events/event-test.c | 6 ++++++
include/libvirt/libvirt-domain.h | 11 ++++++++++-
src/qemu/qemu_monitor.c | 6 +++---
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 10 ++++++++--
src/qemu/qemu_process.c | 22 ++++++++++++++++++++++
tools/virsh-domain.c | 5 ++++-
7 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 12690cac09ce..d3a81eb4a559 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -240,6 +240,12 @@ eventDetailToString(int event,
case VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED:
return "Finished";
+ case VIR_DOMAIN_EVENT_SHUTDOWN_GUEST:
+ return "Killed on a guest request";
+
+ case VIR_DOMAIN_EVENT_SHUTDOWN_HOST:
+ return "Killed on a host request";
+
case VIR_DOMAIN_EVENT_SHUTDOWN_LAST:
break;
}
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index c9e96a6c90bc..de391a9214d1 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2983,7 +2983,16 @@ typedef enum {
* Details on the cause of a 'shutdown' lifecycle event
*/
typedef enum {
- VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0, /* Guest finished shutdown sequence */
+ /* Guest finished shutdown sequence */
+ VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED = 0,
+
+ /* Guest is shutting down due to request from guest (e.g. hardware-specific
+ * action) */
+ VIR_DOMAIN_EVENT_SHUTDOWN_GUEST = 1,
+
+ /* Guest is shutting down due to request from host (e.g. killed by a
+ * signal) */
+ VIR_DOMAIN_EVENT_SHUTDOWN_HOST = 2,
# ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_EVENT_SHUTDOWN_LAST
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2148d483ed6a..a2de1a6c5bad 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1326,13 +1326,13 @@ qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
int
-qemuMonitorEmitShutdown(qemuMonitorPtr mon)
+qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest)
{
int ret = -1;
- VIR_DEBUG("mon=%p", mon);
+ VIR_DEBUG("mon=%p guest=%u", mon, guest);
mon->willhangup = 1;
- QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm);
+ QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm, guest);
return ret;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 12f98beba763..8956bf929aaa 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -130,6 +130,7 @@ typedef int (*qemuMonitorDomainEventCallback)(qemuMonitorPtr mon,
void *opaque);
typedef int (*qemuMonitorDomainShutdownCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
+ virTristateBool guest,
void *opaque);
typedef int (*qemuMonitorDomainResetCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
@@ -344,7 +345,7 @@ int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
long long seconds, unsigned int micros,
const char *details);
-int qemuMonitorEmitShutdown(qemuMonitorPtr mon);
+int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 083729003ba3..757595dd7472 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -523,9 +523,15 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
}
-static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
+static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr data)
{
- qemuMonitorEmitShutdown(mon);
+ bool guest = false;
+ virTristateBool guest_initiated = VIR_TRISTATE_BOOL_ABSENT;
+
+ if (virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
+ guest_initiated = guest ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
+
+ qemuMonitorEmitShutdown(mon, guest_initiated);
}
static void qemuMonitorJSONHandleReset(qemuMonitorPtr mon, virJSONValuePtr data ATTRIBUTE_UNUSED)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c19bd292596a..f7248dac9b89 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -634,10 +634,12 @@ qemuProcessHandleEvent(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
static int
qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
+ virTristateBool guest_initiated,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
qemuDomainObjPrivatePtr priv;
+ virObjectEventPtr pre_event = NULL;
virObjectEventPtr event = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -662,6 +664,25 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjSetState(vm,
VIR_DOMAIN_SHUTDOWN,
VIR_DOMAIN_SHUTDOWN_UNKNOWN);
+
+ switch (guest_initiated) {
+ case VIR_TRISTATE_BOOL_YES:
+ pre_event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_SHUTDOWN,
+ VIR_DOMAIN_EVENT_SHUTDOWN_GUEST);
+ break;
+
+ case VIR_TRISTATE_BOOL_NO:
+ pre_event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_SHUTDOWN,
+ VIR_DOMAIN_EVENT_SHUTDOWN_HOST);
+ break;
+
+ case VIR_TRISTATE_BOOL_ABSENT:
+ case VIR_TRISTATE_BOOL_LAST:
+ break;
+ }
+
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_SHUTDOWN,
VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED);
@@ -678,6 +699,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
unlock:
virObjectUnlock(vm);
+ qemuDomainEventQueue(driver, pre_event);
qemuDomainEventQueue(driver, event);
virObjectUnref(cfg);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0d19d0e0126e..f05dcbdac5bc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -12249,7 +12249,10 @@ VIR_ENUM_IMPL(virshDomainEventStopped,
VIR_ENUM_DECL(virshDomainEventShutdown)
VIR_ENUM_IMPL(virshDomainEventShutdown,
VIR_DOMAIN_EVENT_SHUTDOWN_LAST,
- N_("Finished"))
+ N_("Finished"),
+ N_("Shutting down on a guest request"),
+ N_("Shutting down on a host request"),
+ )
VIR_ENUM_DECL(virshDomainEventPMSuspended)
VIR_ENUM_IMPL(virshDomainEventPMSuspended,
--
2.13.0
7 years, 6 months
[libvirt] [PATCH v3 0/5] Hyper-V method invocation
by Sri Ramanujam
Changes from v2:
* Correctly manage and free invocation parameters
* Fixed a couple of other memory leaks found while fixing the above issue
* Minor code changes from review
I also forgot to mention previously that we have test servers available for
reviewers as we introduce new functionality to the driver. Let me know if you
want access to them :)
Sri Ramanujam (5):
hyperv: Functions to work with invocation parameters.
hyperv: Generate object property type information.
hyperv: add hypervInvokeMethod
hyperv: support virDomainSendKey
hyperv: Add support for virDomainSetMemory
src/hyperv/hyperv_driver.c | 181 +++++++
src/hyperv/hyperv_wmi.c | 891 ++++++++++++++++++++++++++++++++++
src/hyperv/hyperv_wmi.h | 93 +++-
src/hyperv/hyperv_wmi_classes.h | 19 +
src/hyperv/hyperv_wmi_generator.input | 116 +++++
src/hyperv/hyperv_wmi_generator.py | 15 +-
src/hyperv/openwsman.h | 4 +
7 files changed, 1317 insertions(+), 2 deletions(-)
--
2.9.3
7 years, 6 months
[libvirt] [PATCH v2 0/5] qemu: Unbreak aarch64/virt TCG guests
by Andrea Bolognani
Changes from v1:
* address review comments in 3/5;
* all other patches are unchanged.
Andrea Bolognani (5):
qemu: Use qemuDomainMachineIsVirt() more
tests: Check default GIC version for aarch64/virt TCG guests
qemu: Use GICv2 for aarch64/virt TCG guests
gic: Remove VIR_GIC_VERSION_DEFAULT
news: Update for GIC version on TCG changes
docs/news.xml | 11 +++++++++
src/qemu/qemu_capabilities.c | 7 +-----
src/qemu/qemu_command.c | 6 ++---
src/qemu/qemu_domain.c | 26 +++++++++++++++++++---
src/util/virgic.h | 3 ---
.../qemuxml2argv-aarch64-gic-none-tcg.args | 19 ++++++++++++++++
.../qemuxml2argv-aarch64-gic-none-tcg.xml | 17 ++++++++++++++
tests/qemuxml2argvtest.c | 3 +++
.../qemuxml2xmlout-aarch64-gic-none-tcg.xml | 25 +++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
10 files changed, 103 insertions(+), 15 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-tcg.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-tcg.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-tcg.xml
--
2.7.4
7 years, 6 months