[prev in list] [next in list] [prev in thread] [next in thread]
List: libvirt-users
Subject: Re:Re: what a correct use for virConnectDomainEventRegisterAny API, how to Obtain a stable expected
From: "thomas.kuang" <ks002278 () 163 ! com>
Date: 2020-04-15 2:13:22
Message-ID: 563e6cf7.2adb.1717b9cc106.Coremail.ks002278 () 163 ! com
[Download RAW message or body]
[Attachment #2 (text/plain)]
Daniel, thanks for your help.
If it cannot receive a stable expected callback, it need a timer to handle the \
timeout, in the timer timeout to release memory passed to \
virConnectDomainEventRegisterAny or, maybe memory-leak now ...
At 2020-04-14 18:00:49, "Daniel P. Berrang¨¦" <berrange@redhat.com> wrote:
> On Mon, Apr 13, 2020 at 05:32:38PM +0800, thomas.kuang wrote:
> > HI, everyone:
> >
> >
> > My target deal with network hotplug use virDomainDetachDeviceFlags. Because when \
> > the API return ,the network maybe doesn¡¯t remove from my vm guest os.
> > So I use virConnectDomainEventRegisterAny to register an event ID: \
> > VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED ,
> > my process as follow:
> >
> > cb_para->call_id=virConnectDomainEventRegisterAny(cb_para->conn,cb_para->dom,VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, \
> > VIR_DOMAIN_EVENT_CALLBACK(vnf_control_del_network_cb), cb_para, \
> > vnf_control_del_network_cb_free);
> >
> >
> > flags |= VIR_DOMAIN_AFFECT_CONFIG;
> > if (virDomainIsActive(dom) == 1) {
> > flags |= VIR_DOMAIN_AFFECT_LIVE;
> > }
> >
> > ret = virDomainDetachDeviceFlags(dom, xml, flags);
> >
> >
> >
> >
> > above code write in thread loop ,then in the same loop :
> >
> >
> >
> > while (1) {
> >
> > mission = vnf_mission_queue_get(task);
> >
> > if (mission == NULL) {
> >
> > sleep(1);
> >
> > continue;
> >
> > }
> >
> > vnf_op_process(&mission->info); // this will deal with network hotplug,will call \
> > virConnectDomainEventRegisterAny then call virDomainDetachDeviceFlags
> > if (mission) {
> >
> > vnf_mission_free(mission);
> >
> > }
> >
> > if(virEventRunDefaultImpl() < 0) { // at here process the registered callback \
> > for event-registered
> > printf();....
> >
> >
> > }
> >
> > }
> >
> > My problem is: some time , the virEventRunDefaultImpl can trigger the
> > vnf_control_del_network_cb callback ,but some time there is nothing,
> > as if the VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED has lost.
> > what cause the Unpredictable behavior ? what is a correct use for
> > virConnectDomainEventRegisterAny ?
>
> The virDomainDetachDeviceFlags API is asynchronous and requires a cooperative
> guest to complete. It merely injects an ACPI PCI unplug request to the guest
> OS. If the guest OS doesn't honour this request (because it is in early
> bootup, or is in BIOS, or is crashed, or is configured to disable hotplug,
> or is maliciously not responding), then the device will never be unplugged,
> and so you'll never get an event.
>
> So the first thing for you todo is to validate that the device really is
> being unplugged in the guest OS, and in QEMU.
>
> To check QEMU run:
>
> virsh qemu-monitor-command --hmp $GUEST "info pci"
>
> and look to see if the PCI device is still listed in the output.
>
> Regards,
> Daniel
> --
> > > https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> > > https://libvirt.org -o- https://fstop138.berrange.com :|
> > > https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
[Attachment #3 (text/html)]
<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Daniel, \
thanks for your help.</div><div><br></div><div><span style="color: rgb(51, 51, 51); \
font-family: Arial, 'Microsoft YaHei', '\\5FAEÈíÑźÚ', '\\5B8BÌå', 'Malgun Gothic', \
Meiryo, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; \
font-weight: normal; letter-spacing: normal; line-height: 26px; orphans: auto; \
text-align: start; text-indent: 0px; text-transform: none; white-space: normal; \
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: \
rgb(247, 248, 250); display: inline !important; float: none;">If it cannot receive a \
stable expected callback, it need a timer to handle the timeout, in the timer timeout \
to release memory passed to </span>virConnectDomainEventRegisterAny<span \
style="color: rgb(51, 51, 51); font-family: Arial, 'Microsoft YaHei', '\\5FAEÈíÑźÚ', \
'\\5B8BÌå', 'Malgun Gothic', Meiryo, sans-serif; font-size: 14px; font-style: normal; \
font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 26px; \
orphans: auto; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
background-color: rgb(247, 248, 250); display: inline !important; float: \
none;"></span></div><div>or, maybe memory-leak now \
...<br></div><div><br></div><br><pre>At 2020-04-14 18:00:49, "Daniel P. Berrang¨¦" \
<berrange@redhat.com> wrote: >On Mon, Apr 13, 2020 at 05:32:38PM +0800, \
thomas.kuang wrote: >> HI, everyone:
>>
>>
>> My target deal with network hotplug use virDomainDetachDeviceFlags. Because \
when the API return ,the network maybe doesn¡¯t remove from my vm guest os. >>
>> So I use virConnectDomainEventRegisterAny to register an event ID: \
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED , >>
>> my process as follow:
>>
>> cb_para->call_id=virConnectDomainEventRegisterAny(cb_para->conn,cb_para->dom,VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, \
VIR_DOMAIN_EVENT_CALLBACK(vnf_control_del_network_cb), cb_para, \
vnf_control_del_network_cb_free); >>
>>
>>
>> flags |= VIR_DOMAIN_AFFECT_CONFIG;
>> if (virDomainIsActive(dom) == 1) {
>> flags |= VIR_DOMAIN_AFFECT_LIVE;
>> }
>>
>> ret = virDomainDetachDeviceFlags(dom, xml, flags);
>>
>>
>>
>>
>> above code write in thread loop ,then in the same loop :
>>
>>
>>
>> while (1) {
>>
>> mission = vnf_mission_queue_get(task);
>>
>> if (mission == NULL) {
>>
>> sleep(1);
>>
>> continue;
>>
>> }
>>
>> vnf_op_process(&mission->info); // this will deal with \
network hotplug,will call virConnectDomainEventRegisterAny then call \
virDomainDetachDeviceFlags >>
>> if (mission) {
>>
>> vnf_mission_free(mission);
>>
>> }
>>
>> if(virEventRunDefaultImpl() < 0) { // at here process the \
registered callback for event-registered >>
>> printf();....
>>
>>
>> }
>>
>> }
>>
>> My problem is: some time , the virEventRunDefaultImpl can trigger the
>> vnf_control_del_network_cb callback ,but some time there is nothing,
>> as if the VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED has lost.
>> what cause the Unpredictable behavior ? what is a correct use for
>> virConnectDomainEventRegisterAny ?
>
>The virDomainDetachDeviceFlags API is asynchronous and requires a cooperative
>guest to complete. It merely injects an ACPI PCI unplug request to the guest
>OS. If the guest OS doesn't honour this request (because it is in early
>bootup, or is in BIOS, or is crashed, or is configured to disable hotplug,
>or is maliciously not responding), then the device will never be unplugged,
>and so you'll never get an event.
>
>So the first thing for you todo is to validate that the device really is
>being unplugged in the guest OS, and in QEMU.
>
>To check QEMU run:
>
> virsh qemu-monitor-command --hmp $GUEST "info pci"
>
>and look to see if the PCI device is still listed in the output.
>
>Regards,
>Daniel
>--
>|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
>|: https://libvirt.org -o- https://fstop138.berrange.com :|
>|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
</pre></div><br><br><span title="neteasefooter"><p> </p></span>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic