Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On 11/20/14 21:14, Jiri Denemark wrote: On Wed, Nov 19, 2014 at 11:23:19 +0100, Peter Krempa wrote: New qemu added a new event that is emitted when a virtio serial channel is opened in the guest OS. This allows us to update the state of the port in the output-only XML element. This patch implements the monitor callbacks and necessary handlers to update the state in the definition. --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 57 src/qemu/qemu_monitor.c | 14 +++ src/qemu/qemu_monitor.h | 10 src/qemu/qemu_monitor_json.c | 23 ++ src/qemu/qemu_process.c | 44 ++ 6 files changed, 149 insertions(+) I've pushed patches 1-6 with the requested changes. I'll repost the rest later. Thanks. Peter signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On 2014/11/20 15:47, Peter Krempa wrote: the status XML is the piece that is reloaded on libvirtd restart for running VMs. For inactive VMs this doesn't make sense to report. Thanks. I missed status XML in /var/run/libvirt/. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On 11/20/2014 12:47 AM, Peter Krempa wrote: On 11/20/14 08:44, Wang Rui wrote: On 2014/11/19 18:23, Peter Krempa wrote: New qemu added a new event that is emitted when a virtio serial channel is opened in the guest OS. This allows us to update the state of the port in the output-only XML element. Hi, Peter IIUC, QEMU emitted the event and libvirt saved the state for the next time being queryed. 'the output-only XML element' and 'SaveStatus' means the state is not saved persistently. This saves the state of the port into the status XML and In case of libvirtd being restarted after state is saved, we'll lose it. Could we handle this case? the status XML is the piece that is reloaded on libvirtd restart for running VMs. For inactive VMs this doesn't make sense to report. When reconnecting to the QMP monitor after a libvirtd restart, we need to query for whether the agent state has changed in the time that libvirt was not receiving events. At the same time as VSERPORT_CHANGE was added as an event, Laszlo also enhanced the 'query-chardev' command to also poll the current connectedness of the agent channel (qemu commit 32a97ea). This series needs to call that command on reconnect instead of trusting that the state saved prior to libvirtd restart is still valid. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On 11/20/14 14:11, Eric Blake wrote: On 11/20/2014 12:47 AM, Peter Krempa wrote: On 11/20/14 08:44, Wang Rui wrote: On 2014/11/19 18:23, Peter Krempa wrote: New qemu added a new event that is emitted when a virtio serial channel is opened in the guest OS. This allows us to update the state of the port in the output-only XML element. Hi, Peter IIUC, QEMU emitted the event and libvirt saved the state for the next time being queryed. 'the output-only XML element' and 'SaveStatus' means the state is not saved persistently. This saves the state of the port into the status XML and In case of libvirtd being restarted after state is saved, we'll lose it. Could we handle this case? the status XML is the piece that is reloaded on libvirtd restart for running VMs. For inactive VMs this doesn't make sense to report. When reconnecting to the QMP monitor after a libvirtd restart, we need to query for whether the agent state has changed in the time that libvirt was not receiving events. At the same time as VSERPORT_CHANGE was added as an event, Laszlo also enhanced the 'query-chardev' command to also poll the current connectedness of the agent channel (qemu commit 32a97ea). This series needs to call that command on reconnect instead of trusting that the state saved prior to libvirtd restart is still valid. See patch 8/11. Peter signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On Wed, Nov 19, 2014 at 11:23:19 +0100, Peter Krempa wrote: New qemu added a new event that is emitted when a virtio serial channel is opened in the guest OS. This allows us to update the state of the port in the output-only XML element. This patch implements the monitor callbacks and necessary handlers to update the state in the definition. --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 57 src/qemu/qemu_monitor.c | 14 +++ src/qemu/qemu_monitor.h | 10 src/qemu/qemu_monitor_json.c | 23 ++ src/qemu/qemu_process.c | 44 ++ 6 files changed, 149 insertions(+) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ad45a66..e4ea4ce 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -196,6 +196,7 @@ typedef enum { QEMU_PROCESS_EVENT_GUESTPANIC, QEMU_PROCESS_EVENT_DEVICE_DELETED, QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED, +QEMU_PROCESS_EVENT_SERIAL_CHANGED, QEMU_PROCESS_EVENT_LAST } qemuProcessEventType; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a84fd47..31bf6bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4334,6 +4334,60 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver, } +static void +processSerialChangedEvent(virQEMUDriverPtr driver, + virDomainObjPtr vm, + char *devAlias, + bool connected) +{ +virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); +virDomainChrDeviceState newstate; +virDomainDeviceDef dev; + +if (connected) +newstate = VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED; +else +newstate = VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED; + +VIR_DEBUG(Changing serial port state %s in domain %p %s, + devAlias, vm, vm-def-name); + +if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) 0) +goto cleanup; + +if (!virDomainObjIsActive(vm)) { +VIR_DEBUG(Domain is not running); +goto endjob; +} + +if (virDomainDefFindDevice(vm-def, devAlias, dev, true) 0) +goto endjob; + +/* we care only about certain devices */ +if (dev.type != VIR_DOMAIN_DEVICE_CHR || +dev.data.chr-deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL || +dev.data.chr-targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) +goto endjob; + +dev.data.chr-state = newstate; + +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm) 0) +VIR_WARN(unable to save domain status after removing device %s, Looks like a copypaste error :-) ACK with the warning fixed. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On 2014/11/19 18:23, Peter Krempa wrote: New qemu added a new event that is emitted when a virtio serial channel is opened in the guest OS. This allows us to update the state of the port in the output-only XML element. This patch implements the monitor callbacks and necessary handlers to update the state in the definition. --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 57 src/qemu/qemu_monitor.c | 14 +++ src/qemu/qemu_monitor.h | 10 src/qemu/qemu_monitor_json.c | 23 ++ src/qemu/qemu_process.c | 44 ++ 6 files changed, 149 insertions(+) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ad45a66..e4ea4ce 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -196,6 +196,7 @@ typedef enum { QEMU_PROCESS_EVENT_GUESTPANIC, QEMU_PROCESS_EVENT_DEVICE_DELETED, QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED, +QEMU_PROCESS_EVENT_SERIAL_CHANGED, QEMU_PROCESS_EVENT_LAST } qemuProcessEventType; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a84fd47..31bf6bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4334,6 +4334,60 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver, } +static void +processSerialChangedEvent(virQEMUDriverPtr driver, + virDomainObjPtr vm, + char *devAlias, + bool connected) +{ +virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); +virDomainChrDeviceState newstate; +virDomainDeviceDef dev; + +if (connected) +newstate = VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED; +else +newstate = VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED; + +VIR_DEBUG(Changing serial port state %s in domain %p %s, + devAlias, vm, vm-def-name); + +if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) 0) +goto cleanup; + +if (!virDomainObjIsActive(vm)) { +VIR_DEBUG(Domain is not running); +goto endjob; +} + +if (virDomainDefFindDevice(vm-def, devAlias, dev, true) 0) +goto endjob; + +/* we care only about certain devices */ +if (dev.type != VIR_DOMAIN_DEVICE_CHR || +dev.data.chr-deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL || +dev.data.chr-targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) +goto endjob; + +dev.data.chr-state = newstate; + +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm) 0) +VIR_WARN(unable to save domain status after removing device %s, + devAlias); + Hi, Peter IIUC, QEMU emitted the event and libvirt saved the state for the next time being queryed. 'the output-only XML element' and 'SaveStatus' means the state is not saved persistently. In case of libvirtd being restarted after state is saved, we'll lose it. Could we handle this case? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] qemu: Add handling for VSERPORT_CHANGE event
On 11/20/14 08:44, Wang Rui wrote: On 2014/11/19 18:23, Peter Krempa wrote: New qemu added a new event that is emitted when a virtio serial channel is opened in the guest OS. This allows us to update the state of the port in the output-only XML element. This patch implements the monitor callbacks and necessary handlers to update the state in the definition. --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 57 src/qemu/qemu_monitor.c | 14 +++ src/qemu/qemu_monitor.h | 10 src/qemu/qemu_monitor_json.c | 23 ++ src/qemu/qemu_process.c | 44 ++ 6 files changed, 149 insertions(+) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ad45a66..e4ea4ce 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -196,6 +196,7 @@ typedef enum { QEMU_PROCESS_EVENT_GUESTPANIC, QEMU_PROCESS_EVENT_DEVICE_DELETED, QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED, +QEMU_PROCESS_EVENT_SERIAL_CHANGED, QEMU_PROCESS_EVENT_LAST } qemuProcessEventType; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a84fd47..31bf6bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4334,6 +4334,60 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver, } +static void +processSerialChangedEvent(virQEMUDriverPtr driver, + virDomainObjPtr vm, + char *devAlias, + bool connected) +{ +virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); +virDomainChrDeviceState newstate; +virDomainDeviceDef dev; + +if (connected) +newstate = VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED; +else +newstate = VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED; + +VIR_DEBUG(Changing serial port state %s in domain %p %s, + devAlias, vm, vm-def-name); + +if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) 0) +goto cleanup; + +if (!virDomainObjIsActive(vm)) { +VIR_DEBUG(Domain is not running); +goto endjob; +} + +if (virDomainDefFindDevice(vm-def, devAlias, dev, true) 0) +goto endjob; + +/* we care only about certain devices */ +if (dev.type != VIR_DOMAIN_DEVICE_CHR || +dev.data.chr-deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL || +dev.data.chr-targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) +goto endjob; + +dev.data.chr-state = newstate; + +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm) 0) +VIR_WARN(unable to save domain status after removing device %s, + devAlias); + Hi, Peter IIUC, QEMU emitted the event and libvirt saved the state for the next time being queryed. 'the output-only XML element' and 'SaveStatus' means the state is not saved persistently. This saves the state of the port into the status XML and In case of libvirtd being restarted after state is saved, we'll lose it. Could we handle this case? the status XML is the piece that is reloaded on libvirtd restart for running VMs. For inactive VMs this doesn't make sense to report. Peter signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list