Re: [libvirt] [PATCH 1/4] qemu: Escape commas for qemuBuildChrChardevStr
On 06/18/2018 07:37 PM, John Ferlan wrote: > > > On 06/18/2018 01:57 PM, Anya Harter wrote: >> Add comma escaping for dev->data.file.path in cases >> VIR_DOMAIN_CHR_TYPE_DEV and VIR_DOMAIN_CHR_TYPE_PIPE. >> >> Signed-off-by: Anya Harter >> --- >> src/qemu/qemu_command.c | 9 + >> tests/qemuxml2argvdata/name-escape.args | 4 >> tests/qemuxml2argvdata/name-escape.xml | 7 +++ >> tests/qemuxml2argvtest.c| 3 ++- >> 4 files changed, 18 insertions(+), 5 deletions(-) >> > > Having tests is awesome! Thanks! > > Not sure why the bite size tasks omitted VIR_DOMAIN_CHR_TYPE_FILE too. > If you want to investigate the FILE case that'd be good - just to make > sure we aren't missing any! I'll still push this as is since it's fine, > but if the FILE needs something it can be added afterwards. VIR_DOMAIN_CHR_TYPE_FILE calls the function qemuBuildChrChardevFileStr and passes the dev->data.file.path into the parameter named fileval which I escape in the second patch. Please let me know if I am missing something here. Thanks, Anya > > Reviewed-by: John Ferlan > > John > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: Escape commas for qemuBuildDiskThrottling
Add comma escaping for disk->blkdeviotune.group_name. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 4 ++-- tests/qemuxml2argvdata/name-escape.args | 5 + tests/qemuxml2argvdata/name-escape.xml | 13 + tests/qemuxml2argvtest.c| 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 20c6ac2a04..e05b106a5e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1554,8 +1554,8 @@ qemuBuildDiskThrottling(virDomainDiskDefPtr disk, IOTUNE_ADD(size_iops_sec, "iops-size"); if (disk->blkdeviotune.group_name) { -virBufferEscapeString(buf, ",throttling.group=%s", - disk->blkdeviotune.group_name); +virBufferAddLit(buf, ",throttling.group="); +virQEMUBuildBufferEscapeComma(buf, disk->blkdeviotune.group_name); } IOTUNE_ADD(total_bytes_sec_max_length, "bps-total-max-length"); diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index 72ed2e8410..aef7c238ca 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -24,6 +24,11 @@ bar=2/monitor.sock,server,nowait \ -boot c \ -device usb-ccid,id=ccid0,bus=usb.0,port=1 \ -usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ +cache=none,throttling.bps-total=5000,throttling.iops-total=6000,\ +throttling.bps-total-max=1,throttling.iops-total-max=11000,\ +throttling.group=libvirt_iotune_group1,,foo \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -device ccid-card-emulated,backend=certificates,cert1=cert1,,foo,cert2=cert2,\ cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \ -chardev tty,id=charserial0,path=/dev/ttyS2,,foo \ diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 0580de1813..70a1ce09d3 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -14,6 +14,19 @@ destroy /usr/bin/qemu-system-i686 + + + + + +5000 +6000 +1 +11000 +libvirt_iotune_group1,foo + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a9a493e308..582a9de7bb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2758,6 +2758,8 @@ mymain(void) DO_TEST("name-escape", QEMU_CAPS_NAME_DEBUG_THREADS, QEMU_CAPS_OBJECT_SECRET, +QEMU_CAPS_DRIVE_IOTUNE_MAX, +QEMU_CAPS_DRIVE_IOTUNE_GROUP, QEMU_CAPS_VNC, QEMU_CAPS_NAME_GUEST, QEMU_CAPS_DEVICE_CIRRUS_VGA, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2] qemu: add comma escaping in qemuBuildSCSIiSCSIHostdevDrvStr
In order to use the virQEMUBuildBufferEscapeComma function to escape the commas, the function first had to be converted to use a buffer. Added a test case for comma escaping in name-escape.xml. This should complete the BiteSizedTask entry at https://wiki.libvirt.org/page/BiteSizedTasks#qemu:_Use_comma_escaping_for_more_command_line_values. Anya Harter (2): qemu: use virBuffer in qemuBuildSCSIiSCSIHostdevDrvStr qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr src/qemu/qemu_command.c | 19 +-- tests/qemuxml2argvdata/name-escape.args | 6 +- tests/qemuxml2argvdata/name-escape.xml | 7 +++ tests/qemuxml2argvtest.c| 5 - 4 files changed, 29 insertions(+), 8 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] qemu: use virBuffer in qemuBuildSCSIiSCSIHostdevDrvStr
Instead of source to enable use of virBuffer functions in string construction. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e05b106a5e..a99240992a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4657,7 +4657,8 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { -char *source = NULL; +virBuffer buf = VIR_BUFFER_INITIALIZER; + char *netsource = NULL; virJSONValuePtr srcprops = NULL; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; @@ -4670,21 +4671,25 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, goto cleanup; if (!(netsource = virQEMUBuildDriveCommandlineFromJSON(srcprops))) goto cleanup; -if (virAsprintf(&source, "%s,if=none,format=raw", netsource) < 0) -goto cleanup; +virBufferAsprintf(&buf, "%s,if=none,format=raw", netsource); } else { /* Rather than pull what we think we want - use the network disk code */ if (!(netsource = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ? srcPriv->secinfo : NULL))) goto cleanup; -if (virAsprintf(&source, "file=%s,if=none,format=raw", netsource) < 0) -goto cleanup; +virBufferAsprintf(&buf, "file=%s,if=none,format=raw", netsource); } +if (virBufferCheckError(&buf) < 0) +goto cleanup; + +return virBufferContentAndReset(&buf); + cleanup: VIR_FREE(netsource); virJSONValueFree(srcprops); -return source; +virBufferFreeAndReset(&buf); +return NULL; } char * -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr
Add comma escaping for netsource Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 4 +++- tests/qemuxml2argvdata/name-escape.args | 6 +- tests/qemuxml2argvdata/name-escape.xml | 7 +++ tests/qemuxml2argvtest.c| 5 - 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a99240992a..96c6c08c2d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4677,7 +4677,9 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, if (!(netsource = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ? srcPriv->secinfo : NULL))) goto cleanup; -virBufferAsprintf(&buf, "file=%s,if=none,format=raw", netsource); +virBufferAddLit(&buf, "file="); +virQEMUBuildBufferEscapeComma(&buf, netsource); +virBufferAddLit(&buf, ",if=none,format=raw"); } if (virBufferCheckError(&buf) < 0) diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index aef7c238ca..1cbb1efd66 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -22,6 +22,7 @@ bar=2/monitor.sock,server,nowait \ -no-shutdown \ -no-acpi \ -boot c \ +-device lsi,id=scsi0,bus=pci.0,addr=0x3 \ -device usb-ccid,id=ccid0,bus=usb.0,port=1 \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ @@ -41,4 +42,7 @@ cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \ -spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock,gl=on,\ rendernode=/dev/dri/foo,,bar \ -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 +-drive file=iscsi://example,,foo.org:3260/iqn.1992-01.com.example/0,if=none,\ +format=raw,id=drive-hostdev0 \ +-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 70a1ce09d3..24dd248842 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -27,6 +27,13 @@ + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 582a9de7bb..2e891a0bea 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2772,7 +2772,10 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_FILE_APPEND, -QEMU_CAPS_CCID_EMULATED); +QEMU_CAPS_CCID_EMULATED, +QEMU_CAPS_VIRTIO_SCSI, +QEMU_CAPS_SCSI_LSI, +QEMU_CAPS_DEVICE_SCSI_GENERIC); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4] qemu: Escape commas for qemuBuildGrapicsSPICECommandLine
On 06/19/2018 10:46 AM, Cole Robinson wrote: > On 06/19/2018 09:47 AM, Cole Robinson wrote: >> On 06/18/2018 07:52 PM, John Ferlan wrote: >>> >>> >>> On 06/18/2018 01:57 PM, Anya Harter wrote: >>>> Add comma escaping for cfg->spiceTLSx509certdir and >>>> graphics->data.spice.rendernode. >>>> >>>> Signed-off-by: Anya Harter >>>> --- >>>> src/qemu/qemu_command.c | 11 --- >>>> tests/qemuxml2argvdata/name-escape.args | 5 +++-- >>>> tests/qemuxml2argvdata/name-escape.xml | 1 + >>>> tests/qemuxml2argvtest.c| 5 + >>>> 4 files changed, 17 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c >>>> index a9a5e200e9..36dccea9b2 100644 >>>> --- a/src/qemu/qemu_command.c >>>> +++ b/src/qemu/qemu_command.c >>>> @@ -7974,8 +7974,11 @@ >>>> qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, >>>> !cfg->spicePassword) >>>> virBufferAddLit(&opt, "disable-ticketing,"); >>>> >>>> -if (hasSecure) >>>> -virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir); >>>> +if (hasSecure) { >>>> +virBufferAddLit(&opt, "x509-dir="); >>>> +virQEMUBuildBufferEscapeComma(&opt, cfg->spiceTLSx509certdir); >>>> +virBufferAsprintf(&opt, ","); >>> >>> make syntax-check would have told you: >>> >>> src/qemu/qemu_command.c:7980:virBufferAsprintf(&opt, ","); >>> src/qemu/qemu_command.c:8090:virBufferAsprintf(&opt, ","); >>> >>> So here and below, I changed to virBufferAddLit before pushing. >>> >>>> +} >>>> >>>> switch (graphics->data.spice.defaultMode) { >>>> case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: >>>> @@ -8082,7 +8085,9 @@ >>>> qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, >>>> goto error; >>>> } >>>> >>>> -virBufferAsprintf(&opt, "rendernode=%s,", >>>> graphics->data.spice.rendernode); >>>> +virBufferAddLit(&opt, "rendernode="); >>>> +virQEMUBuildBufferEscapeComma(&opt, >>>> graphics->data.spice.rendernode); >>>> +virBufferAsprintf(&opt, ","); >>>> } >>>> } >>> >>> Reviewed-by: John Ferlan >>> >>> John >>> >>> >From the last time I passed through this when Sukrit posted patches, >>> still to do are qemuBuildHostNetStr, qemuBuildDiskThrottling (for group >>> name), and various qemuBuildNetworkDriveURI, qemuBuildNetworkDriveStr, >>> and qemuGetDriveSourceString. >>> >> >> Oh cool, I didn't realize you had found more examples! I looked at some >> of these with Anya before the patch series. >> >> NetworkDriveURI is a private subset of NetworkDriveStr, so the former >> doesn't need any direct changes AFAICT. >> >> qemuGetDriveSourceString is called outside qemu_command.c, for example >> passing the result to qemu monitor commands. Anyone know if comma >> escaping applies there too? Same with qemuBuildHostNetStr >> > > From what I can tell qemuGetDriveSourceString and qemuBuildHostNetStr > usages outside of qemu_command.c should _not_ have comma escaping, which > makes sense as the comma isn't used as a delimiter in those substrings. > So the comma escaping should be done at the call sites of those > functions in qemu_command.c By my estimation the BiteSizedTask entry https://wiki.libvirt.org/page/BiteSizedTasks#qemu:_Use_comma_escaping_for_more_command_line_values is complete. The four bullet points have been addressed as follows: * Building the source drive string in qemuBuildNetworkDriveURI, qemuBuildNetworkDriveStr, and qemuGetDriveSourceString (src->hosts->socket, NBD exportname=src->path, Sheepdog src->path processing, rbd src->path & configFile processing) Since some of these functions are called from outside the building of the command line, escaping within the functions could lead to problems elsewhere. Thus, the approach is to escape the output of the functions from their callers. All calls to qemuBuildNetworkDriveURI
Re: [libvirt] [PATCH 2/2] qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr
On 06/21/2018 06:55 PM, John Ferlan wrote: > > > On 06/20/2018 09:17 AM, Anya Harter wrote: >> Add comma escaping for netsource >> >> Signed-off-by: Anya Harter >> --- >> src/qemu/qemu_command.c | 4 +++- >> tests/qemuxml2argvdata/name-escape.args | 6 +- >> tests/qemuxml2argvdata/name-escape.xml | 7 +++ >> tests/qemuxml2argvtest.c| 5 - >> 4 files changed, 19 insertions(+), 3 deletions(-) >> >> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c >> index a99240992a..96c6c08c2d 100644 >> --- a/src/qemu/qemu_command.c >> +++ b/src/qemu/qemu_command.c >> @@ -4677,7 +4677,9 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr >> dev, >> if (!(netsource = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ? >> srcPriv->secinfo : >> NULL))) >> goto cleanup; >> -virBufferAsprintf(&buf, "file=%s,if=none,format=raw", netsource); >> +virBufferAddLit(&buf, "file="); >> +virQEMUBuildBufferEscapeComma(&buf, netsource); >> +virBufferAddLit(&buf, ",if=none,format=raw"); >> } >> >> if (virBufferCheckError(&buf) < 0) >> diff --git a/tests/qemuxml2argvdata/name-escape.args >> b/tests/qemuxml2argvdata/name-escape.args >> index aef7c238ca..1cbb1efd66 100644 >> --- a/tests/qemuxml2argvdata/name-escape.args >> +++ b/tests/qemuxml2argvdata/name-escape.args >> @@ -22,6 +22,7 @@ bar=2/monitor.sock,server,nowait \ >> -no-shutdown \ >> -no-acpi \ >> -boot c \ >> +-device lsi,id=scsi0,bus=pci.0,addr=0x3 \ > > [1] > >> -device usb-ccid,id=ccid0,bus=usb.0,port=1 \ >> -usb \ >> -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ >> @@ -41,4 +42,7 @@ >> cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \ >> -spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock,gl=on,\ >> rendernode=/dev/dri/foo,,bar \ >> -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \ >> --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 >> +-drive >> file=iscsi://example,,foo.org:3260/iqn.1992-01.com.example/0,if=none,\ >> +format=raw,id=drive-hostdev0 \ >> +-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 >> \ >> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 >> diff --git a/tests/qemuxml2argvdata/name-escape.xml >> b/tests/qemuxml2argvdata/name-escape.xml >> index 70a1ce09d3..24dd248842 100644 >> --- a/tests/qemuxml2argvdata/name-escape.xml >> +++ b/tests/qemuxml2argvdata/name-escape.xml >> @@ -27,6 +27,13 @@ >> >> >> >> + > > [1] If you change this to: > > > > Then the lsi doesn't show up... > >> + >> + >> + >> + > > Something is not quite right about seeing "example,foo.org" as a host > name. I don't see that as a valid host name regardless of comma > escaping. Do we escape commas in other "" string > fields? I don't see it being done for qemuBuildChrChardevStr (search on > TCP or "host.*name" in qemu_command.c)> > Now the one thing that perhaps *could* be escaped is the name > attribute. Currently it's set to "iqn.1992-01.com.example", but the spec > defines a structure of that name field to have a field that is a "String > defined by the naming authority" (shorter version, see > https://en.wikipedia.org/wiki/ISCSI) > > So if the name is : 'iqn.1992-01.com.example:storage/2', then the > "storage/2" piece is the string defined by the naming authority. Not > that I know whether it would work, but that's where I suppose a comma > could go. If you could give me a string with a comma in it, I would be happy to put it into the test instead of in the host name field. However, if no one can think of a realistic case where comma escaping would be necessary, we can just remove the test altogether. I only put it in as a test that implementation was correct and that the commas were actually being escaped correctly. > >> + >> + >> >> >> >> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c >> index 582a9de7bb..2e891a0bea 100644 >> --- a/tests/qemuxml2argvtest.c >> +++ b/tests/qemuxml2argvtest.c >> @@ -2772,7 +2772,10 @@ mymain(void) >> QEMU_CAPS_DEVICE_VIDEO_PRIMARY, >> QEMU_CAPS_DEVICE_ISA_SERIAL, >> QEMU_CAPS_CHARDEV_FILE_APPEND, >> -QEMU_CAPS_CCID_EMULATED); >> +QEMU_CAPS_CCID_EMULATED, >> +QEMU_CAPS_VIRTIO_SCSI, >> +QEMU_CAPS_SCSI_LSI, > > [1] and the LSI wouldn't be needed here. > > John > > first patch looks fine, but I'm not so convinced on this one only > because of the host name w/ a comma. > >> +QEMU_CAPS_DEVICE_SCSI_GENERIC); >> DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); >> >> DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); >> -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH] connect: fix deregistering of NodeDevice events
Signed-off-by: Anya Harter --- src/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connect.c b/src/connect.c index 09e5628..32dda14 100644 --- a/src/connect.c +++ b/src/connect.c @@ -68,7 +68,7 @@ virtDBusConnectClose(virtDBusConnect *connect, for (gint i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) { if (connect->nodeDevCallbackIds[i] >= 0) { if (deregisterEvents) { -virConnectNetworkEventDeregisterAny(connect->connection, +virConnectNodeDeviceEventDeregisterAny(connect->connection, connect->nodeDevCallbackIds[i]); } connect->nodeDevCallbackIds[i] = -1; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr
On 06/26/2018 08:52 AM, John Ferlan wrote: > > > On 06/22/2018 09:06 AM, Anya Harter wrote: > [...] > >>> >>> Something is not quite right about seeing "example,foo.org" as a host >>> name. I don't see that as a valid host name regardless of comma >>> escaping. Do we escape commas in other "" string >>> fields? I don't see it being done for qemuBuildChrChardevStr (search on >>> TCP or "host.*name" in qemu_command.c)> >>> Now the one thing that perhaps *could* be escaped is the name >>> attribute. Currently it's set to "iqn.1992-01.com.example", but the spec >>> defines a structure of that name field to have a field that is a "String >>> defined by the naming authority" (shorter version, see >>> https://en.wikipedia.org/wiki/ISCSI) >>> >>> So if the name is : 'iqn.1992-01.com.example:storage/2', then the >>> "storage/2" piece is the string defined by the naming authority. Not >>> that I know whether it would work, but that's where I suppose a comma >>> could go. >> >> If you could give me a string with a comma in it, I would be happy to >> put it into the test instead of in the host name field. However, if no >> one can think of a realistic case where comma escaping would be >> necessary, we can just remove the test altogether. I only put it in as a >> test that implementation was correct and that the commas were actually >> being escaped correctly. >> > > Sorry for the delay - I stuck my head into the checkpoint/backup > quicksand and it's been "difficult" to remove it ;-) > > So going back to your analysis from the previous series: > > https://www.redhat.com/archives/libvir-list/2018-June/msg01467.html > > Now I see where/why you got here. The myopia I have is that host->name > shouldn't have a comma in it as it's an invalid address format. > > So, rather than: > > > > if I instead use: > > > > then with a couple of adjustments to input: > > - > + > > ... > > - > - > + > + > > qemuxml2argvtest.c: > > -QEMU_CAPS_SCSI_LSI, > > and output: > > --device lsi,id=scsi0,bus=pci.0,addr=0x3 \ > +-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \ > > ... > > --drive file=iscsi://example,,foo.org:3260/iqn.1992-01.com.example/0,if=none,\ > -format=raw,id=drive-hostdev0 \ > --device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \ > +-drive file=iscsi://example.foo.org:3260/iqn.1992-01.com.example%3Amy,,\ > +storage/1,if=none,format=raw,id=drive-hostdev0 \ > +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,lun=4,\ > +drive=drive-hostdev0,id=hostdev0 \ > > Then, I think we cover this oddball case. > > I can make those changes for you before pushing as long as you > agree that's fine. In the long run, it's similar, it's just avoiding > the invalid hostname/uri string. I think that sounds good. Thanks, Anya > > John > > and yes, once this is pushed, that item comes off the wiki list. > > [...] > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] qemu: move qemuDomainCCWAddrSetCreateFromDomain
from src/qemu/qemu_domain_address.[ch] to src/conf/domain_addr.[ch] Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 24 src/conf/domain_addr.h | 4 src/qemu/qemu_domain_address.c | 22 -- src/qemu/qemu_domain_address.h | 4 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 39f22b82eb..6c39608e01 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1209,6 +1209,30 @@ virDomainCCWAddressSetCreate(void) } +virDomainCCWAddressSetPtr +qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) +{ +virDomainCCWAddressSetPtr addrs = NULL; + +if (!(addrs = virDomainCCWAddressSetCreate())) +goto error; + +if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate, + addrs) < 0) +goto error; + +if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate, + addrs) < 0) +goto error; + +return addrs; + + error: +virDomainCCWAddressSetFree(addrs); +return NULL; +} + + #define VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS 31 diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 3236b7d6de..039efcaaf1 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -205,6 +205,10 @@ int virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void); +virDomainCCWAddressSetPtr +qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) +ATTRIBUTE_NONNULL(1); + struct _virDomainVirtioSerialController { unsigned int idx; virBitmapPtr ports; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index e9f460d77a..b1aef64d89 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -376,28 +376,6 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, } } -virDomainCCWAddressSetPtr -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) -{ -virDomainCCWAddressSetPtr addrs = NULL; - -if (!(addrs = virDomainCCWAddressSetCreate())) -goto error; - -if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate, - addrs) < 0) -goto error; - -if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate, - addrs) < 0) -goto error; - -return addrs; - - error: -virDomainCCWAddressSetFree(addrs); -return NULL; -} /* * Three steps populating CCW devnos diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 83f8e81cad..89d7a5ac3e 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -59,10 +59,6 @@ void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, virDomainDeviceInfoPtr info, const char *devstr); -virDomainCCWAddressSetPtr -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) -ATTRIBUTE_NONNULL(1); - int qemuDomainAssignMemoryDeviceSlot(virDomainDefPtr def, virDomainMemoryDefPtr mem); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] domain_addr: refactor qemuDomainCCWAddrSetCreateFromDomain
to virDomainCCWAddrSetCreateFromDomain Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 2 +- src/conf/domain_addr.h | 2 +- src/qemu/qemu_domain_address.c | 4 ++-- src/qemu/qemu_hotplug.c| 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 6c39608e01..5730b3b859 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1210,7 +1210,7 @@ virDomainCCWAddressSetCreate(void) virDomainCCWAddressSetPtr -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) +virDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) { virDomainCCWAddressSetPtr addrs = NULL; diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 039efcaaf1..35530e464c 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -206,7 +206,7 @@ int virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs, virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void); virDomainCCWAddressSetPtr -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) +virDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) ATTRIBUTE_NONNULL(1); struct _virDomainVirtioSerialController { diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index b1aef64d89..cf29b4be9b 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -398,7 +398,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, qemuDomainPrimeVirtioDeviceAddresses( def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW); -if (!(addrs = qemuDomainCCWAddrSetCreateFromDomain(def))) +if (!(addrs = virDomainCCWAddrSetCreateFromDomain(def))) goto cleanup; } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390)) { @@ -3005,7 +3005,7 @@ qemuDomainEnsureVirtioAddress(bool *releaseAddr, } if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { -if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def))) +if (!(ccwaddrs = virDomainCCWAddrSetCreateFromDomain(vm->def))) goto cleanup; if (virDomainCCWAddressAssign(info, ccwaddrs, !info->addr.ccw.assigned) < 0) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index fcd8eb0ffa..21e86ddbfe 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -964,7 +964,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (qemuDomainIsS390CCW(vm->def) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) { net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; -if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def))) +if (!(ccwaddrs = virDomainCCWAddrSetCreateFromDomain(vm->def))) goto cleanup; if (virDomainCCWAddressAssign(&net->info, ccwaddrs, !net->info.addr.ccw.assigned) < 0) @@ -2375,7 +2375,7 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver, if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) goto cleanup; } else if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { -if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def))) +if (!(ccwaddrs = virDomainCCWAddrSetCreateFromDomain(vm->def))) goto cleanup; if (virDomainCCWAddressAssign(hostdev->info, ccwaddrs, !hostdev->info->addr.ccw.assigned) < 0) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2] domain_addr: move qemu function and rename
qemuDomainCCWAddrSetCreateFromDomain moved from qemu_domain_addr to domain_addr and rename to virDomainCCWAddrSetCreateFromDomain because it is not a qemu-specific function Anya Harter (2): qemu: move qemuDomainCCWAddrSetCreateFromDomain domain_addr: refactor qemuDomainCCWAddrSetCreateFromDomain src/conf/domain_addr.c | 24 src/conf/domain_addr.h | 4 src/qemu/qemu_domain_address.c | 26 ++ src/qemu/qemu_domain_address.h | 4 src/qemu/qemu_hotplug.c| 4 ++-- 5 files changed, 32 insertions(+), 30 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] domain_addr: delete virDomainVirtioSerialAddrRelease
the last use of this function was deleted in commit 19a148b7c8353d5c214bed699f8fe983317baf93 Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 44 src/conf/domain_addr.h | 5 - src/libvirt_private.syms | 1 - 3 files changed, 50 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 9786adf937..271696ba3a 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1631,50 +1631,6 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def ATTRIBUTE_UNUSED, return ret; } -/* virDomainVirtioSerialAddrRelease - * - * Release the virtio serial address of the device - */ -int -virDomainVirtioSerialAddrRelease(virDomainVirtioSerialAddrSetPtr addrs, - virDomainDeviceInfoPtr info) -{ -virBitmapPtr map; -char *str = NULL; -int ret = -1; -ssize_t i; - -if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL || -info->addr.vioserial.port == 0) -return 0; - -VIR_DEBUG("Releasing virtio serial %u %u", info->addr.vioserial.controller, - info->addr.vioserial.port); - -i = virDomainVirtioSerialAddrFindController(addrs, info->addr.vioserial.controller); -if (i < 0) { -virReportError(VIR_ERR_XML_ERROR, - _("virtio serial controller %u is missing"), - info->addr.vioserial.controller); -goto cleanup; -} - -map = addrs->controllers[i]->ports; -if (virBitmapClearBit(map, info->addr.vioserial.port) < 0) { -virReportError(VIR_ERR_XML_ERROR, - _("virtio serial controller %u does not have port %u"), - info->addr.vioserial.controller, - info->addr.vioserial.port); -goto cleanup; -} - -ret = 0; - - cleanup: -VIR_FREE(str); -return ret; -} - bool virDomainUSBAddressPortIsValid(unsigned int *port) diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 2db649484a..bd7cf08e47 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -262,11 +262,6 @@ virDomainVirtioSerialAddrReserve(virDomainDefPtr def, void *data) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); -int -virDomainVirtioSerialAddrRelease(virDomainVirtioSerialAddrSetPtr addrs, - virDomainDeviceInfoPtr info) -ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - bool virDomainUSBAddressPortIsValid(unsigned int *port) ATTRIBUTE_NONNULL(1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cd2e4280ab..b87e81391a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -139,7 +139,6 @@ virDomainVirtioSerialAddrAssign; virDomainVirtioSerialAddrAutoAssign; virDomainVirtioSerialAddrAutoAssignFromCache; virDomainVirtioSerialAddrIsComplete; -virDomainVirtioSerialAddrRelease; virDomainVirtioSerialAddrReserve; virDomainVirtioSerialAddrSetAddControllers; virDomainVirtioSerialAddrSetCreate; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] domain_addr: delete virDomainCCWAddressReleaseAddr
the last use of this function was deleted in commit 1aa5e66cf3a0dd5e8ada8483f79cb745f786a131 Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 24 src/conf/domain_addr.h | 3 --- src/libvirt_private.syms | 1 - 3 files changed, 28 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 5730b3b859..9786adf937 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1152,30 +1152,6 @@ virDomainCCWAddressValidate(virDomainDefPtr def ATTRIBUTE_UNUSED, return virDomainCCWAddressAssign(info, data, false); } -int -virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs, - virDomainDeviceInfoPtr dev) -{ -char *addr; -int ret; - -addr = virDomainCCWAddressAsString(&(dev->addr.ccw)); -if (!addr) -return -1; - -if ((ret = virHashRemoveEntry(addrs->defined, addr)) == 0 && -dev->addr.ccw.cssid == addrs->next.cssid && -dev->addr.ccw.ssid == addrs->next.ssid && -dev->addr.ccw.devno < addrs->next.devno) { -addrs->next.devno = dev->addr.ccw.devno; -addrs->next.assigned = false; -} - -VIR_FREE(addr); - -return ret; -} - void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs) { if (!addrs) diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 35530e464c..2db649484a 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -200,9 +200,6 @@ int virDomainCCWAddressValidate(virDomainDefPtr def, void *data) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); -int virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs, - virDomainDeviceInfoPtr dev) -ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void); virDomainCCWAddressSetPtr diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5499a368c0..cd2e4280ab 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -106,7 +106,6 @@ virPCIDeviceAddressParseXML; # conf/domain_addr.h virDomainCCWAddressAllocate; virDomainCCWAddressAssign; -virDomainCCWAddressReleaseAddr; virDomainCCWAddressSetCreate; virDomainCCWAddressSetFree; virDomainCCWAddressValidate; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2] domain_addr: delete unused functions
each commit references the commit where the last use was removed Anya Harter (2): domain_addr: delete virDomainCCWAddressReleaseAddr domain_addr: delete virDomainVirtioSerialAddrRelease src/conf/domain_addr.c | 68 src/conf/domain_addr.h | 8 - src/libvirt_private.syms | 2 -- 3 files changed, 78 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH] connect: fix g_free order in virtDBusConnectFree
so that g_free(connect->nodeDevPath) line appears in alphabetical order with the rest of the lines Signed-off-by: Anya Harter --- src/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connect.c b/src/connect.c index 9ebceaa..9275121 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1808,9 +1808,9 @@ virtDBusConnectFree(virtDBusConnect *connect) if (connect->connection) virtDBusConnectClose(connect, TRUE); -g_free(connect->nodeDevPath); g_free(connect->domainPath); g_free(connect->networkPath); +g_free(connect->nodeDevPath); g_free(connect->nwfilterPath); g_free(connect->secretPath); g_free(connect->storagePoolPath); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] qemu: move qemuDomainCCWAddrSetCreateFromDomain
On 07/02/2018 04:48 PM, John Ferlan wrote: > > > On 06/28/2018 04:23 PM, Anya Harter wrote: >> from src/qemu/qemu_domain_address.[ch] to src/conf/domain_addr.[ch] >> >> Signed-off-by: Anya Harter >> --- >> src/conf/domain_addr.c | 24 >> src/conf/domain_addr.h | 4 >> src/qemu/qemu_domain_address.c | 22 -- >> src/qemu/qemu_domain_address.h | 4 >> 4 files changed, 28 insertions(+), 26 deletions(-) >> > > While I can appreciate the 2 patch approach for ease of review, patch 1 > and patch 2 should be combined. Once you move a function into src/conf/* > - give it the vir* prefix. > > Since you now have a function inside src/conf called from a driver, you > must add the function to src/libvirt_private.syms (otherwise your build > fails - at least mine did). > Woops! I missed that step. > Additionally, once patches are combined virDomainCCWAddressSetCreate, > virDomainCCWAddressValidate, and virDomainCCWAddressAllocate (moved in > this patch) all become local/static to domain_addr and thus can be > removed from domain_addr.h and libvirt_private.syms I'm going to do this as part of a separate patch series which makes several functions static which are unused elsewhere. > > John > > BTW: The ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) from the .h file that > would then be "lost" could be added after the "static int" in the .c > file, although that's not a requirement. We're finding those are really > only useful if someone pass NULL as an argument and less useful if an > argument itself is NULL (which isn't the case here). I will keep this in mind for my other patch series. Thanks, Anya > >> diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c >> index 39f22b82eb..6c39608e01 100644 >> --- a/src/conf/domain_addr.c >> +++ b/src/conf/domain_addr.c >> @@ -1209,6 +1209,30 @@ virDomainCCWAddressSetCreate(void) >> } >> >> >> +virDomainCCWAddressSetPtr >> +qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) >> +{ >> +virDomainCCWAddressSetPtr addrs = NULL; >> + >> +if (!(addrs = virDomainCCWAddressSetCreate())) >> +goto error; >> + >> +if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate, >> + addrs) < 0) >> +goto error; >> + >> +if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate, >> + addrs) < 0) >> +goto error; >> + >> +return addrs; >> + >> + error: >> +virDomainCCWAddressSetFree(addrs); >> +return NULL; >> +} >> + >> + >> #define VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS 31 >> >> >> diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h >> index 3236b7d6de..039efcaaf1 100644 >> --- a/src/conf/domain_addr.h >> +++ b/src/conf/domain_addr.h >> @@ -205,6 +205,10 @@ int >> virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs, >> ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); >> virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void); >> >> +virDomainCCWAddressSetPtr >> +qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) >> +ATTRIBUTE_NONNULL(1); >> + >> struct _virDomainVirtioSerialController { >> unsigned int idx; >> virBitmapPtr ports; >> diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c >> index e9f460d77a..b1aef64d89 100644 >> --- a/src/qemu/qemu_domain_address.c >> +++ b/src/qemu/qemu_domain_address.c >> @@ -376,28 +376,6 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr >> def, >> } >> } >> >> -virDomainCCWAddressSetPtr >> -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) >> -{ >> -virDomainCCWAddressSetPtr addrs = NULL; >> - >> -if (!(addrs = virDomainCCWAddressSetCreate())) >> -goto error; >> - >> -if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate, >> - addrs) < 0) >> -goto error; >> - >> -if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate, >> - addrs) < 0) >> -goto error; >> - >> -return addrs; >> - >> - error: >> -virDomainCCWAddressSetFree(addrs); >> -return NULL; >> -} >> >> /* >> * Three steps populating CCW devnos >>
[libvirt] [PATCH v2] qemu: move qemuDomainCCWAddrSetCreateFromDomain
from src/qemu/qemu_domain_address.c to src/conf/domain_addr.c and rename to virDomainCCWAddressSetCreateFromDomain (rename to have Address in full instead of Addr to follow the naming convention of other virDomainCCWAddress functions) Signed-off-by: Anya Harter --- renamed function in v2 patch (reason supplied in commit message) original patch email: https://www.redhat.com/archives/libvir-list/2018-June/msg01823.html src/conf/domain_addr.c | 24 src/conf/domain_addr.h | 4 src/libvirt_private.syms | 1 + src/qemu/qemu_domain_address.c | 26 ++ src/qemu/qemu_domain_address.h | 4 src/qemu/qemu_hotplug.c| 4 ++-- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index fd66a74e9d..eb0784cd2c 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1185,6 +1185,30 @@ virDomainCCWAddressSetCreate(void) } +virDomainCCWAddressSetPtr +virDomainCCWAddressSetCreateFromDomain(virDomainDefPtr def) +{ +virDomainCCWAddressSetPtr addrs = NULL; + +if (!(addrs = virDomainCCWAddressSetCreate())) +goto error; + +if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate, + addrs) < 0) +goto error; + +if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate, + addrs) < 0) +goto error; + +return addrs; + + error: +virDomainCCWAddressSetFree(addrs); +return NULL; +} + + #define VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS 31 diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 2764070cd2..776399eb63 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -202,6 +202,10 @@ int virDomainCCWAddressValidate(virDomainDefPtr def, virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void); +virDomainCCWAddressSetPtr +virDomainCCWAddressSetCreateFromDomain(virDomainDefPtr def) +ATTRIBUTE_NONNULL(1); + struct _virDomainVirtioSerialController { unsigned int idx; virBitmapPtr ports; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ffe5dfd19b..7000620b41 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -107,6 +107,7 @@ virPCIDeviceAddressParseXML; virDomainCCWAddressAllocate; virDomainCCWAddressAssign; virDomainCCWAddressSetCreate; +virDomainCCWAddressSetCreateFromDomain; virDomainCCWAddressSetFree; virDomainCCWAddressValidate; virDomainPCIAddressAsString; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index e9f460d77a..eb11a660d7 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -376,28 +376,6 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, } } -virDomainCCWAddressSetPtr -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) -{ -virDomainCCWAddressSetPtr addrs = NULL; - -if (!(addrs = virDomainCCWAddressSetCreate())) -goto error; - -if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate, - addrs) < 0) -goto error; - -if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate, - addrs) < 0) -goto error; - -return addrs; - - error: -virDomainCCWAddressSetFree(addrs); -return NULL; -} /* * Three steps populating CCW devnos @@ -420,7 +398,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def, qemuDomainPrimeVirtioDeviceAddresses( def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW); -if (!(addrs = qemuDomainCCWAddrSetCreateFromDomain(def))) +if (!(addrs = virDomainCCWAddressSetCreateFromDomain(def))) goto cleanup; } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390)) { @@ -3027,7 +3005,7 @@ qemuDomainEnsureVirtioAddress(bool *releaseAddr, } if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { -if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def))) +if (!(ccwaddrs = virDomainCCWAddressSetCreateFromDomain(vm->def))) goto cleanup; if (virDomainCCWAddressAssign(info, ccwaddrs, !info->addr.ccw.assigned) < 0) diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 83f8e81cad..89d7a5ac3e 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -59,10 +59,6 @@ void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, virDomainDeviceInfoPtr info, const char *devstr); -virDomainCCWAddressSetPtr -qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def) -ATTRIBUTE_NONNULL(1); - int qemuDomainAssignMemoryDeviceSlot(virDomainDefPtr def, virDomainMemoryDefPtr mem); diff --git
Re: [libvirt] [dbus PATCH] connect: fix g_free order in virtDBusConnectFree
On 07/03/2018 09:03 AM, Ján Tomko wrote: > On Tue, Jul 03, 2018 at 02:18:02PM +0200, Pavel Hrdina wrote: >> On Mon, Jul 02, 2018 at 11:42:08AM -0400, Anya Harter wrote: >>> so that g_free(connect->nodeDevPath) line appears in alphabetical order >>> with the rest of the lines >>> >>> Signed-off-by: Anya Harter >>> --- >>> src/connect.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> In general we don't send/merge patches that just move code without any >> functional reason because it pollutes git history but in this case I >> would say it's ok. >> > > What about the gchar *nodeDevPath; declaration in connect.h? > It is also in a different order. This is a good catch. How would you do something that isn't functional as part of a different commit? Wouldn't it confuse someone looking at it? Thanks, Anya > > /me runs > > Jano > >> Reviewed-by: Pavel Hrdina and pushed. > > > >> -- >> libvir-list mailing list >> libvir-list@redhat.com >> https://www.redhat.com/mailman/listinfo/libvir-list > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/4] domain_addr: make virDomainCCWAddress funcs static
Allocate, Validate, SetCreate last uses of these functions outside domain_addr.c removed in commit: 7bdd06b4e103269992122603949f585fc2bfdc6 Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 6 +++--- src/conf/domain_addr.h | 12 src/libvirt_private.syms | 3 --- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index ec2dfdbbdc..1922412853 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1134,7 +1134,7 @@ virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, return ret; } -int +static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) virDomainCCWAddressAllocate(virDomainDefPtr def ATTRIBUTE_UNUSED, virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED, virDomainDeviceInfoPtr info, @@ -1143,7 +1143,7 @@ virDomainCCWAddressAllocate(virDomainDefPtr def ATTRIBUTE_UNUSED, return virDomainCCWAddressAssign(info, data, true); } -int +static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) virDomainCCWAddressValidate(virDomainDefPtr def ATTRIBUTE_UNUSED, virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED, virDomainDeviceInfoPtr info, @@ -1161,7 +1161,7 @@ void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs) VIR_FREE(addrs); } -virDomainCCWAddressSetPtr +static virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void) { virDomainCCWAddressSetPtr addrs = NULL; diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index fc87c14eba..fc5ddcf6f1 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -186,18 +186,6 @@ int virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, bool autoassign) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs); -int virDomainCCWAddressAllocate(virDomainDefPtr def, -virDomainDeviceDefPtr dev, -virDomainDeviceInfoPtr info, -void *data) -ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); -int virDomainCCWAddressValidate(virDomainDefPtr def, -virDomainDeviceDefPtr dev, -virDomainDeviceInfoPtr info, -void *data) -ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); - -virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void); virDomainCCWAddressSetPtr virDomainCCWAddressSetCreateFromDomain(virDomainDefPtr def) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7000620b41..fef38d29fa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -104,12 +104,9 @@ virPCIDeviceAddressParseXML; # conf/domain_addr.h -virDomainCCWAddressAllocate; virDomainCCWAddressAssign; -virDomainCCWAddressSetCreate; virDomainCCWAddressSetCreateFromDomain; virDomainCCWAddressSetFree; -virDomainCCWAddressValidate; virDomainPCIAddressAsString; virDomainPCIAddressBusIsFullyReserved; virDomainPCIAddressBusSetModel; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/4] domain_addr: make functions static
which are unused outside domain_addr.c The commit where the last external use was removed is linked in each commit when it exists Anya Harter (4): domain_addr: make virDomainPCIAddressBusIsEmpty static domain_addr: make virDomainCCWAddress funcs static domain_addr: make virDomainVirtioSerialAddr funcs static domain_addr: make virDomainUSBAddressPortFormat static src/conf/domain_addr.c | 197 +++ src/conf/domain_addr.h | 39 src/libvirt_private.syms | 8 -- 3 files changed, 98 insertions(+), 146 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/4] domain_addr: make virDomainVirtioSerialAddr funcs static
SetCreate, SetAddControllers, Reserve last uses of these functions outside domain_addr.c removed in commit: 40c284f0a6b53a182af7b12173bcb5dd3eb0c826 Assign never used outside domain_addr.c move Assign and Reserve above their first call within domain_addr.c Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 187 +++ src/conf/domain_addr.h | 21 - src/libvirt_private.syms | 4 - 3 files changed, 93 insertions(+), 119 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 1922412853..33f859697b 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1216,7 +1216,7 @@ virDomainCCWAddressSetCreateFromDomain(virDomainDefPtr def) * * Allocates an address set for virtio serial addresses */ -virDomainVirtioSerialAddrSetPtr +static virDomainVirtioSerialAddrSetPtr virDomainVirtioSerialAddrSetCreate(void) { virDomainVirtioSerialAddrSetPtr ret = NULL; @@ -1318,7 +1318,7 @@ virDomainVirtioSerialAddrSetAddController(virDomainVirtioSerialAddrSetPtr addrs, * Adds virtio serial ports of controllers present in the domain definition * to the address set. */ -int +static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs, virDomainDefPtr def) { @@ -1346,6 +1346,65 @@ virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs) } } +/* virDomainVirtioSerialAddrReserve + * + * Reserve the virtio serial address of the device + * + * For use with virDomainDeviceInfoIterate, + * opaque should be the address set + */ +static int ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) +virDomainVirtioSerialAddrReserve(virDomainDefPtr def ATTRIBUTE_UNUSED, + virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED, + virDomainDeviceInfoPtr info, + void *data) +{ +virDomainVirtioSerialAddrSetPtr addrs = data; +char *str = NULL; +int ret = -1; +virBitmapPtr map = NULL; +bool b; +ssize_t i; + +if (!virDomainVirtioSerialAddrIsComplete(info)) +return 0; + +VIR_DEBUG("Reserving virtio serial %u %u", info->addr.vioserial.controller, + info->addr.vioserial.port); + +i = virDomainVirtioSerialAddrFindController(addrs, info->addr.vioserial.controller); +if (i < 0) { +virReportError(VIR_ERR_XML_ERROR, + _("virtio serial controller %u is missing"), + info->addr.vioserial.controller); +goto cleanup; +} + +map = addrs->controllers[i]->ports; +if (virBitmapGetBit(map, info->addr.vioserial.port, &b) < 0) { +virReportError(VIR_ERR_XML_ERROR, + _("virtio serial controller %u does not have port %u"), + info->addr.vioserial.controller, + info->addr.vioserial.port); +goto cleanup; +} + +if (b) { +virReportError(VIR_ERR_XML_ERROR, + _("virtio serial port %u on controller %u is already occupied"), + info->addr.vioserial.port, + info->addr.vioserial.controller); +goto cleanup; +} + +ignore_value(virBitmapSetBit(map, info->addr.vioserial.port)); + +ret = 0; + + cleanup: +VIR_FREE(str); +return ret; +} /* virDomainVirtioSerialAddrSetCreateFromDomain * @@ -1487,6 +1546,38 @@ virDomainVirtioSerialAddrNextFromController(virDomainVirtioSerialAddrSetPtr addr return 0; } +static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) +virDomainVirtioSerialAddrAssign(virDomainDefPtr def, +virDomainVirtioSerialAddrSetPtr addrs, +virDomainDeviceInfoPtr info, +bool allowZero, +bool portOnly) +{ +int ret = -1; +virDomainDeviceInfo nfo = { 0 }; +virDomainDeviceInfoPtr ptr = allowZero ? &nfo : info; + +ptr->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL; + +if (portOnly) { +if (virDomainVirtioSerialAddrNextFromController(addrs, +&ptr->addr.vioserial) < 0) +goto cleanup; +} else { +if (virDomainVirtioSerialAddrNext(def, addrs, &ptr->addr.vioserial, + allowZero) < 0) +goto cleanup; +} + +if (virDomainVirtioSerialAddrReserve(NULL, NULL, ptr, addrs) < 0) +goto cleanup; + +ret = 0; + + cleanup: +return ret; +} + /* virDomainVirtioSerialAddrAutoAssign * * reserve a virtio serial address of the device (if it has one) @@ -1528,38 +1619,6 @@ virDo
[libvirt] [PATCH 1/4] domain_addr: make virDomainPCIAddressBusIsEmpty static
never used outside domain_addr.c Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 2 +- src/conf/domain_addr.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index eb0784cd2c..ec2dfdbbdc 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -386,7 +386,7 @@ virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus) } -bool +static bool ATTRIBUTE_NONNULL(1) virDomainPCIAddressBusIsEmpty(virDomainPCIAddressBusPtr bus) { size_t i; diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 776399eb63..fc87c14eba 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -146,9 +146,6 @@ int virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, bool virDomainPCIAddressBusIsFullyReserved(virDomainPCIAddressBusPtr bus) ATTRIBUTE_NONNULL(1); -bool virDomainPCIAddressBusIsEmpty(virDomainPCIAddressBusPtr bus) -ATTRIBUTE_NONNULL(1); - bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/4] domain_addr: make virDomainUSBAddressPortFormat static
never used outside domain_addr.c Signed-off-by: Anya Harter --- src/conf/domain_addr.c | 2 +- src/conf/domain_addr.h | 3 --- src/libvirt_private.syms | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 33f859697b..16f7ffa928 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1653,7 +1653,7 @@ virDomainUSBAddressPortFormatBuf(virBufferPtr buf, } -char * +static char * ATTRIBUTE_NONNULL(1) virDomainUSBAddressPortFormat(unsigned int *port) { virBuffer buf = VIR_BUFFER_INITIALIZER; diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index a94d4bda66..5ad9d8ef3d 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -234,9 +234,6 @@ void virDomainUSBAddressPortFormatBuf(virBufferPtr buf, unsigned int *port) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -char * -virDomainUSBAddressPortFormat(unsigned int *port) -ATTRIBUTE_NONNULL(1); # define VIR_DOMAIN_USB_HUB_PORTS 8 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0f82f3c38a..3e304907b9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -123,7 +123,6 @@ virDomainPCIControllerModelToConnectType; virDomainUSBAddressAssign; virDomainUSBAddressCountAllPorts; virDomainUSBAddressEnsure; -virDomainUSBAddressPortFormat; virDomainUSBAddressPortFormatBuf; virDomainUSBAddressPortIsValid; virDomainUSBAddressPresent; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH] connect: fix gchar declaration in connect.h
so that gchar *nodeDevPath; line appears in alphabetical order with the rest of the lines Signed-off-by: Anya Harter --- src/connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connect.h b/src/connect.h index b81b6a8..0b9ae10 100644 --- a/src/connect.h +++ b/src/connect.h @@ -12,9 +12,9 @@ struct virtDBusConnect { GDBusConnection *bus; const gchar *uri; const gchar *connectPath; -gchar *nodeDevPath; gchar *domainPath; gchar *networkPath; +gchar *nodeDevPath; gchar *nwfilterPath; gchar *secretPath; gchar *storagePoolPath; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH] gitignore: add tests/.pytest_cache
Signed-off-by: Anya Harter --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ca9e4e1..c41c82c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ vgcore.* /src/org.libvirt.service /tests/test_util +/tests/.pytest_cache -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 10/15] Implement InterfaceLookupByName method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 6 ++ src/connect.c| 29 + 2 files changed, 35 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 7c97117..f99e205 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -170,6 +170,12 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/> + + + https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> diff --git a/src/connect.c b/src/connect.c index 563535c..51a6ba0 100644 --- a/src/connect.c +++ b/src/connect.c @@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectInterfaceLookupByName(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *path = NULL; +const gchar *name; + +g_variant_get(inArgs, "(s)", &name); + +if (!virtDBusConnectOpen(connect, NULL)) +return; + +interface = virInterfaceLookupByName(connect->connection, name); +if (!interface) +return virtDBusUtilSetLastVirtError(error); + +path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + +*outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectListDomains(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1899,6 +1927,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, +{ "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 04/15] Implement Active property for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 4 src/interface.c| 22 ++ 2 files changed, 26 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index e6d9f2a..f50bc37 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -13,5 +13,9 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive"/> + diff --git a/src/interface.c b/src/interface.c index 2b62304..b73e116 100644 --- a/src/interface.c +++ b/src/interface.c @@ -66,7 +66,29 @@ virtDBusInterfaceGetMACString(const gchar *objectPath, *value = g_variant_new("s", mac); } +static void +virtDBusInterfaceGetActive(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +gint active; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +active = virInterfaceIsActive(interface); +if (active < 0) +return virtDBusUtilSetLastVirtError(error); + +*value = g_variant_new("b", !!active); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ "Active", virtDBusInterfaceGetActive, NULL }, { "MACString", virtDBusInterfaceGetMACString, NULL }, { "Name", virtDBusInterfaceGetName, NULL }, { 0 } -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 00/15] Implement Interface APIs
https://libvirt.org/html/libvirt-libvirt-interface.html The following functions have been implemented: - virConnectListAllInterfaces (connect method) - virInterfaceChangeBegin (connect method) - virInterfaceChangeCommit (connect method) - virInterfaceChangeRollback(connect method) - virInterfaceCreate(interface method) - virInterfaceDefineXML (connect method) - virInterfaceDestroy (interface method) - virInterfaceGetMACString (property) - virInterfaceGetName (property) - virInterfaceGetXMLDesc(interface method) - virInterfaceIsActive (property) - virInterfaceLookupByMACString (connect method) - virInterfaceLookupByName (connect method) - virInterfaceUndefine (interface method) Anya Harter (15): Introduce Interface Interface Implement Name property for Interface Interface Implement MACString property for Interface Interface Implement Active property for Interface Interface Implement ListInterfaces method for Connect Interface Implement InterfaceDefineXML method for Connect Interface Implement InterfaceChangeBegin method for Connect Interface Implement InterfaceChangeCommit method for Connect Interface Implement InterfaceChangeRollback method for Connect Interface Implement InterfaceLookupByName method for Connect Interface Implement InterfaceLookupByMACString method for Connect Interface Implement Create method for Interface Interface Implement Destroy method for Interface Interface Implement Undefine method for Interface Interface Implement GetXMLDesc method for Interface Interface data/Makefile.am | 1 + data/org.libvirt.Connect.xml | 40 ++ data/org.libvirt.Interface.xml | 41 ++ src/Makefile.am| 2 + src/connect.c | 198 ++ src/connect.h | 1 + src/interface.c| 249 + src/interface.h| 9 ++ src/util.c | 35 + src/util.h | 15 ++ 10 files changed, 591 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 02/15] Implement Name property for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 93fa32f..ad7c326 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,5 +3,10 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/> + + diff --git a/src/interface.c b/src/interface.c index 6dbc702..733ce44 100644 --- a/src/interface.c +++ b/src/interface.c @@ -24,7 +24,29 @@ virtDBusInterfaceGetVirInterface(virtDBusConnect *connect, return interface; } +static void +virtDBusInterfaceGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +const gchar *name; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +name = virInterfaceGetName(interface); +if (!name) +return virtDBusUtilSetLastVirtError(error); + +*value = g_variant_new("s", name); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ "Name", virtDBusInterfaceGetName, NULL }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 13/15] Implement Destroy method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 24 2 files changed, 29 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index f62346a..16caba1 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -22,5 +22,10 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + + diff --git a/src/interface.c b/src/interface.c index dec980a..54a4c6b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -110,6 +110,29 @@ virtDBusInterfaceCreate(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceDestroy(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +if (virInterfaceDestroy(interface, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { "Active", virtDBusInterfaceGetActive, NULL }, { "MACString", virtDBusInterfaceGetMACString, NULL }, @@ -119,6 +142,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, +{ "Destroy", virtDBusInterfaceDestroy }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 09/15] Implement InterfaceChangeRollback method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 5 + src/connect.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 8c88cc8..7c97117 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -158,6 +158,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeCommit"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeRollback"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index dadfd96..563535c 100644 --- a/src/connect.c +++ b/src/connect.c @@ -777,6 +777,27 @@ virtDBusConnectInterfaceChangeCommit(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusConnectInterfaceChangeRollback(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virInterfaceChangeRollback(connect->connection, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1876,6 +1897,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, +{ "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 03/15] Implement MACString property for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index ad7c326..e6d9f2a 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -8,5 +8,10 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> + + diff --git a/src/interface.c b/src/interface.c index 733ce44..2b62304 100644 --- a/src/interface.c +++ b/src/interface.c @@ -45,7 +45,29 @@ virtDBusInterfaceGetName(const gchar *objectPath, *value = g_variant_new("s", name); } +static void +virtDBusInterfaceGetMACString(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +const gchar *mac; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +mac = virInterfaceGetMACString(interface); +if (!mac) +return virtDBusUtilSetLastVirtError(error); + +*value = g_variant_new("s", mac); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ "MACString", virtDBusInterfaceGetMACString, NULL }, { "Name", virtDBusInterfaceGetName, NULL }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 06/15] Implement InterfaceDefineXML method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 7 +++ src/connect.c| 30 ++ 2 files changed, 37 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 0604841..791e1f5 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -148,6 +148,13 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> + + + + https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> diff --git a/src/connect.c b/src/connect.c index a3d002e..8c39d52 100644 --- a/src/connect.c +++ b/src/connect.c @@ -735,6 +735,35 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectInterfaceDefineXML(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *path = NULL; +const gchar *xml; +guint flags; + +g_variant_get(inArgs, "(&su)", &xml, &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +interface = virInterfaceDefineXML(connect->connection, xml, flags); +if (!interface) +return virtDBusUtilSetLastVirtError(error); + +path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + +*outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectListDomains(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1803,6 +1832,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetCPUModelNames", virtDBusConnectGetCPUModelNames }, { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, +{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 07/15] Implement InterfaceChangeBegin method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 5 + src/connect.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 791e1f5..604afea 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -148,6 +148,11 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeBegin"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 8c39d52..7cf2d66 100644 --- a/src/connect.c +++ b/src/connect.c @@ -735,6 +735,27 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectInterfaceChangeBegin(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath G_GNUC_UNUSED, +gpointer userData, +GVariant **outArgs G_GNUC_UNUSED, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virInterfaceChangeBegin(connect->connection, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1832,6 +1853,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetCPUModelNames", virtDBusConnectGetCPUModelNames }, { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, +{ "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 11/15] Implement InterfaceLookupByMACString method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 6 ++ src/connect.c| 29 + 2 files changed, 35 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index f99e205..535d225 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -170,6 +170,12 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByMACString"/> + + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/> diff --git a/src/connect.c b/src/connect.c index 51a6ba0..f611965 100644 --- a/src/connect.c +++ b/src/connect.c @@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectInterfaceLookupByMACString(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *path = NULL; +const gchar *macstr; + +g_variant_get(inArgs, "(s)", &macstr); + +if (!virtDBusConnectOpen(connect, NULL)) +return; + +interface = virInterfaceLookupByMACString(connect->connection, macstr); +if (!interface) +return virtDBusUtilSetLastVirtError(error); + +path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + +*outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectInterfaceLookupByName(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1927,6 +1955,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, +{ "InterfaceLookupByMACString", virtDBusConnectInterfaceLookupByMACString }, { "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 01/15] Introduce Interface Interface
Signed-off-by: Anya Harter --- data/Makefile.am | 1 + data/org.libvirt.Interface.xml | 7 +++ src/Makefile.am| 2 + src/connect.c | 6 +++ src/connect.h | 1 + src/interface.c| 86 ++ src/interface.h| 9 src/util.c | 35 ++ src/util.h | 15 ++ 9 files changed, 162 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h diff --git a/data/Makefile.am b/data/Makefile.am index 7b523da..35a0bbd 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -33,6 +33,7 @@ polkit_DATA = \ interfaces_files = \ org.libvirt.Connect.xml \ org.libvirt.Domain.xml \ + org.libvirt.Interface.xml \ org.libvirt.Network.xml \ org.libvirt.NodeDevice.xml \ org.libvirt.NWFilter.xml \ diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml new file mode 100644 index 000..93fa32f --- /dev/null +++ b/data/org.libvirt.Interface.xml @@ -0,0 +1,7 @@ +http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";> + + + + + diff --git a/src/Makefile.am b/src/Makefile.am index b5bf129..d0e8f0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,6 +41,8 @@ libvirt_dbus_SOURCES = \ events.h \ gdbus.c \ gdbus.h \ + interface.c \ + interface.h \ main.c \ network.c \ network.h \ diff --git a/src/connect.c b/src/connect.c index 9ebceaa..b10533a 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1,6 +1,7 @@ #include "connect.h" #include "domain.h" #include "events.h" +#include "interface.h" #include "network.h" #include "nodedev.h" #include "nwfilter.h" @@ -1810,6 +1811,7 @@ virtDBusConnectFree(virtDBusConnect *connect) g_free(connect->nodeDevPath); g_free(connect->domainPath); +g_free(connect->interfacePath); g_free(connect->networkPath); g_free(connect->nwfilterPath); g_free(connect->secretPath); @@ -1869,6 +1871,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, if (error && *error) return; +virtDBusInterfaceRegister(connect, error); +if (error && *error) +return; + virtDBusNetworkRegister(connect, error); if (error && *error) return; diff --git a/src/connect.h b/src/connect.h index b81b6a8..f755534 100644 --- a/src/connect.h +++ b/src/connect.h @@ -14,6 +14,7 @@ struct virtDBusConnect { const gchar *connectPath; gchar *nodeDevPath; gchar *domainPath; +gchar *interfacePath; gchar *networkPath; gchar *nwfilterPath; gchar *secretPath; diff --git a/src/interface.c b/src/interface.c new file mode 100644 index 000..6dbc702 --- /dev/null +++ b/src/interface.c @@ -0,0 +1,86 @@ +#include "interface.h" +#include "util.h" + +#include + +static virInterfacePtr +virtDBusInterfaceGetVirInterface(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ +virInterfacePtr interface; + +if (virtDBusConnectOpen(connect, error) < 0) +return NULL; + +interface = virtDBusUtilVirInterfaceFromBusPath(connect->connection, +objectPath, +connect->interfacePath); +if (!interface) { +virtDBusUtilSetLastVirtError(error); +return NULL; +} + +return interface; +} + +static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ 0 } +}; + +static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { +{ 0 } +}; + +static gchar ** +virtDBusInterfaceEnumerate(gpointer userData) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterfacePtr) interfaces = NULL; +gint num = 0; +gchar **ret = NULL; + +if (!virtDBusConnectOpen(connect, NULL)) +return NULL; + +num = virConnectListAllInterfaces(connect->connection, &interfaces, 0); +if (num < 0) +return NULL; + +if (num == 0) +return NULL; + +ret = g_new0(gchar *, num + 1); + +for (gint i = 0; i < num; i++) { +ret[i] = virtDBusUtilBusPathForVirInterface(interfaces[i], +connect->interfacePath); +} + +return ret; +} + +static GDBusInterfaceInfo *interfaceInfo; + +void +virtDBusInterfaceRegister(virtDBusConnect *connect, + GError **error) +{ +connect->interfacePath = g_strdup_printf("%s/interface", + connect->connectPath); + +if (!interfaceInfo) {
[libvirt] [dbus PATCH 15/15] Implement GetXMLDesc method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 6 ++ src/interface.c| 28 2 files changed, 34 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 5ca366c..efe59e3 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -27,6 +27,12 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetXMLDesc"/> + + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> diff --git a/src/interface.c b/src/interface.c index 07e1aba..83dbdbe 100644 --- a/src/interface.c +++ b/src/interface.c @@ -133,6 +133,33 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetXMLDesc(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath, +gpointer userData, +GVariant **outArgs, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *xml = NULL; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +xml = virInterfaceGetXMLDesc(interface, flags); +if (!xml) +return virtDBusUtilSetLastVirtError(error); + +*outArgs = g_variant_new("(s)", xml); +} + static void virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -163,6 +190,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, +{ "GetXMLDesc", virtDBusInterfaceGetXMLDesc }, { "Undefine", virtDBusInterfaceUndefine }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 14/15] Implement Undefine method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 4 src/interface.c| 21 + 2 files changed, 25 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 16caba1..5ca366c 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -27,5 +27,9 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> + diff --git a/src/interface.c b/src/interface.c index 54a4c6b..07e1aba 100644 --- a/src/interface.c +++ b/src/interface.c @@ -133,6 +133,26 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +if (virInterfaceUndefine(interface) < 0) +virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { "Active", virtDBusInterfaceGetActive, NULL }, { "MACString", virtDBusInterfaceGetMACString, NULL }, @@ -143,6 +163,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, +{ "Undefine", virtDBusInterfaceUndefine }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 05/15] Implement ListInterfaces method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 6 ++ src/connect.c| 38 2 files changed, 44 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 7014a09..0604841 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -154,6 +154,12 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virConnectListAllInterfaces"/> + + + https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListAllNetworks"/> diff --git a/src/connect.c b/src/connect.c index b10533a..a3d002e 100644 --- a/src/connect.c +++ b/src/connect.c @@ -772,6 +772,43 @@ virtDBusConnectListDomains(GVariant *inArgs, *outArgs = g_variant_new_tuple(&gdomains, 1); } +static void +virtDBusConnectListInterfaces(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterfacePtr) interfaces = NULL; +guint flags; +GVariantBuilder builder; +GVariant *ginterfaces; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virConnectListAllInterfaces(connect->connection, &interfaces, flags) < 0) +return virtDBusUtilSetLastVirtError(error); + +g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + +for (gint i = 0; interfaces[i]; i++) { +g_autofree gchar *path = NULL; +path = virtDBusUtilBusPathForVirInterface(interfaces[i], + connect->interfacePath); + +g_variant_builder_add(&builder, "o", path); +} + +ginterfaces = g_variant_builder_end(&builder); +*outArgs = g_variant_new_tuple(&ginterfaces, 1); +} + static void virtDBusConnectListNetworks(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1767,6 +1804,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListDomains", virtDBusConnectListDomains }, +{ "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, { "ListNodeDevices", virtDBusConnectListNodeDevices }, { "ListNWFilters", virtDBusConnectListNWFilters }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 12/15] Implement Create method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 24 2 files changed, 29 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index f50bc37..f62346a 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -17,5 +17,10 @@ https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> + + diff --git a/src/interface.c b/src/interface.c index b73e116..dec980a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -87,6 +87,29 @@ virtDBusInterfaceGetActive(const gchar *objectPath, *value = g_variant_new("b", !!active); } +static void +virtDBusInterfaceCreate(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath, +gpointer userData, +GVariant **outArgs G_GNUC_UNUSED, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +if (virInterfaceCreate(interface, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { "Active", virtDBusInterfaceGetActive, NULL }, { "MACString", virtDBusInterfaceGetMACString, NULL }, @@ -95,6 +118,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { }; static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { +{ "Create", virtDBusInterfaceCreate }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH 08/15] Implement InterfaceChangeCommit method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 5 + src/connect.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 604afea..8c88cc8 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -153,6 +153,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeBegin"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeCommit"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 7cf2d66..dadfd96 100644 --- a/src/connect.c +++ b/src/connect.c @@ -756,6 +756,27 @@ virtDBusConnectInterfaceChangeBegin(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusConnectInterfaceChangeCommit(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virInterfaceChangeCommit(connect->connection, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1854,6 +1875,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, +{ "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH] test_connect: fix methods to follow naming conventions
Signed-off-by: Anya Harter --- tests/test_connect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_connect.py b/tests/test_connect.py index 7084397..2299b8a 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -22,7 +22,7 @@ class TestConnect(libvirttest.BaseTestClass): self.main_loop() -def test_comnect_domain_define_xml(self): +def test_connect_domain_define_xml(self): def domain_defined(path, event, detail): if event != libvirttest.DomainEvent.DEFINED: return @@ -84,7 +84,7 @@ class TestConnect(libvirttest.BaseTestClass): sysinfo = self.connect.GetSysinfo(0) assert isinstance(sysinfo, dbus.String) -def test_list_networks(self): +def test_connect_list_networks(self): networks = self.connect.ListNetworks(0) assert isinstance(networks, dbus.Array) assert len(networks) == 1 -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2] gitignore: add tests/.pytest_cache
Signed-off-by: Anya Harter --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ca9e4e1..b2021d4 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ vgcore.* /src/org.libvirt.service /tests/test_util +**/.pytest_cache -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH v2] gitignore: add tests/.pytest_cache
On 07/10/2018 11:13 AM, Andrea Bolognani wrote: > On Tue, 2018-07-10 at 10:00 -0400, Anya Harter wrote: >> gitignore: add tests/.pytest_cache >> >> Signed-off-by: Anya Harter > > The commit message should have been adjusted - you're ignoring > all .pytest_cache/ directories now, not just the one in tests/ :) > > [...] >> @@ -44,3 +44,4 @@ vgcore.* >> /src/org.libvirt.service >> >> /tests/test_util >> +**/.pytest_cache > > From gitignore(5): > > A leading "**" followed by a slash means match in all > directories. For example, "**/foo" matches file or directory > "foo" anywhere, the same as pattern "foo". > > So the first three characters are entirely unnecessary here: I've > dropped them, moved the pattern further up in the file (among all > other non-directory-specific patterns), fixed the commit message, > added my > > Reviewed-by: Andrea Bolognani > > and pushed the commit. Sorry, I'm still pretty new to .gitignore files. :) Thanks! Anya > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 00/17] Implement and Test Interface APIs
original patch series cover letter: https://www.redhat.com/archives/libvir-list/2018-July/msg00364.html changes since v1: * all commits "make" and "make check" * MACString property => MAC property * various corrections * add tests for all but virConnectListAllInterfaces, virInterfaceChangeBegin, virInterfaceChangeCommit, and virInterfaceChangeRollback * commits were reordered to introduce functions before they are needed by the test suite https://libvirt.org/html/libvirt-libvirt-interface.html The following functions have been implemented: - virConnectListAllInterfaces (connect method) - virInterfaceChangeBegin (connect method) - virInterfaceChangeCommit (connect method) - virInterfaceChangeRollback(connect method) - virInterfaceCreate(interface method) - virInterfaceDefineXML (connect method) - virInterfaceDestroy (interface method) - virInterfaceGetMACString (property) - virInterfaceGetName (property) - virInterfaceGetXMLDesc(interface method) - virInterfaceIsActive (property) - virInterfaceLookupByMACString (connect method) - virInterfaceLookupByName (connect method) - virInterfaceUndefine (interface method) Anya Harter (17): Introduce Interface Interface Implement InterfaceDefineXML method for Connect Interface Implement Create method for Interface Interface Implement Destroy method for Interface Interface Introduce Interface Tests & Test Create method for Interface Interface Test Destroy method for Interface Interface Implement Undefine method for Interface Interface Implement GetXMLDesc method for Interface Interface Implement Name property for Interface Interface Implement MAC property for Interface Interface Implement Active property for Interface Interface Implement ListInterfaces method for Connect Interface Implement InterfaceChangeBegin method for Connect Interface Implement InterfaceChangeCommit method for Connect Interface Implement InterfaceChangeRollback method for Connect Interface Implement InterfaceLookupByName method for Connect Interface Implement InterfaceLookupByMAC method for Connect Interface data/Makefile.am | 1 + data/org.libvirt.Connect.xml | 40 ++ data/org.libvirt.Interface.xml | 42 ++ src/Makefile.am| 2 + src/connect.c | 198 ++ src/connect.h | 1 + src/interface.c| 249 + src/interface.h| 9 ++ src/util.c | 35 + src/util.h | 15 ++ tests/Makefile.am | 1 + tests/libvirttest.py | 12 ++ tests/test_connect.py | 17 +++ tests/test_interface.py| 39 ++ tests/xmldata.py | 12 ++ 15 files changed, 673 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h create mode 100755 tests/test_interface.py -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 08/17] Implement GetXMLDesc method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 6 ++ src/interface.c| 28 tests/test_interface.py| 4 3 files changed, 38 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 4534b97..dc03258 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -13,6 +13,12 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetXMLDesc"/> + + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> diff --git a/src/interface.c b/src/interface.c index a2d1cef..fcec623 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,33 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetXMLDesc(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath, +gpointer userData, +GVariant **outArgs, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *xml = NULL; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +xml = virInterfaceGetXMLDesc(interface, flags); +if (!xml) +return virtDBusUtilSetLastVirtError(error); + +*outArgs = g_variant_new("(s)", xml); +} + static void virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -97,6 +124,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, +{ "GetXMLDesc", virtDBusInterfaceGetXMLDesc }, { "Undefine", virtDBusInterfaceUndefine }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index 4a83672..0b5a943 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -21,5 +21,9 @@ class TestInterface(libvirttest.BaseTestClass): interface_obj.Destroy(0) interface_obj.Create(0) +def test_interface_get_xml_description(self): +_,interface_obj = self.interface_create() +assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) + if __name__ == '__main__': libvirttest.run() -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 01/17] Introduce Interface Interface
Signed-off-by: Anya Harter --- data/Makefile.am | 1 + data/org.libvirt.Interface.xml | 7 src/Makefile.am| 2 ++ src/connect.c | 6 src/connect.h | 1 + src/interface.c| 65 ++ src/interface.h| 9 + src/util.c | 35 ++ src/util.h | 15 9 files changed, 141 insertions(+) create mode 100644 data/org.libvirt.Interface.xml create mode 100644 src/interface.c create mode 100644 src/interface.h diff --git a/data/Makefile.am b/data/Makefile.am index 7b523da..35a0bbd 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -33,6 +33,7 @@ polkit_DATA = \ interfaces_files = \ org.libvirt.Connect.xml \ org.libvirt.Domain.xml \ + org.libvirt.Interface.xml \ org.libvirt.Network.xml \ org.libvirt.NodeDevice.xml \ org.libvirt.NWFilter.xml \ diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml new file mode 100644 index 000..93fa32f --- /dev/null +++ b/data/org.libvirt.Interface.xml @@ -0,0 +1,7 @@ +http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";> + + + + + diff --git a/src/Makefile.am b/src/Makefile.am index b5bf129..d0e8f0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,6 +41,8 @@ libvirt_dbus_SOURCES = \ events.h \ gdbus.c \ gdbus.h \ + interface.c \ + interface.h \ main.c \ network.c \ network.h \ diff --git a/src/connect.c b/src/connect.c index 9275121..3dc434d 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1,6 +1,7 @@ #include "connect.h" #include "domain.h" #include "events.h" +#include "interface.h" #include "network.h" #include "nodedev.h" #include "nwfilter.h" @@ -1809,6 +1810,7 @@ virtDBusConnectFree(virtDBusConnect *connect) virtDBusConnectClose(connect, TRUE); g_free(connect->domainPath); +g_free(connect->interfacePath); g_free(connect->networkPath); g_free(connect->nodeDevPath); g_free(connect->nwfilterPath); @@ -1869,6 +1871,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, if (error && *error) return; +virtDBusInterfaceRegister(connect, error); +if (error && *error) +return; + virtDBusNetworkRegister(connect, error); if (error && *error) return; diff --git a/src/connect.h b/src/connect.h index 0b9ae10..961b115 100644 --- a/src/connect.h +++ b/src/connect.h @@ -13,6 +13,7 @@ struct virtDBusConnect { const gchar *uri; const gchar *connectPath; gchar *domainPath; +gchar *interfacePath; gchar *networkPath; gchar *nodeDevPath; gchar *nwfilterPath; diff --git a/src/interface.c b/src/interface.c new file mode 100644 index 000..3c32f0f --- /dev/null +++ b/src/interface.c @@ -0,0 +1,65 @@ +#include "interface.h" +#include "util.h" + +#include + +static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ 0 } +}; + +static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { +{ 0 } +}; + +static gchar ** +virtDBusInterfaceEnumerate(gpointer userData) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterfacePtr) interfaces = NULL; +gint num = 0; +gchar **ret = NULL; + +if (!virtDBusConnectOpen(connect, NULL)) +return NULL; + +num = virConnectListAllInterfaces(connect->connection, &interfaces, 0); +if (num < 0) +return NULL; + +if (num == 0) +return NULL; + +ret = g_new0(gchar *, num + 1); + +for (gint i = 0; i < num; i++) { +ret[i] = virtDBusUtilBusPathForVirInterface(interfaces[i], +connect->interfacePath); +} + +return ret; +} + +static GDBusInterfaceInfo *interfaceInfo; + +void +virtDBusInterfaceRegister(virtDBusConnect *connect, + GError **error) +{ +connect->interfacePath = g_strdup_printf("%s/interface", + connect->connectPath); + +if (!interfaceInfo) { +interfaceInfo = virtDBusGDBusLoadIntrospectData(VIRT_DBUS_INTERFACE_INTERFACE, +error); +if (!interfaceInfo) +return; +} + +virtDBusGDBusRegisterSubtree(connect->bus, + connect->interfacePath, + interfaceInfo, + virtDBusInterfaceEnumerate, + virtDBusInterfaceMethodTable, + virtDBusInterfacePropertyTable, + connect); +} diff --git a/src
[libvirt] [dbus PATCH v2 02/17] Implement InterfaceDefineXML method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 7 +++ src/connect.c| 30 ++ tests/test_connect.py| 4 tests/xmldata.py | 12 4 files changed, 53 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 7014a09..f690bab 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -148,6 +148,13 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> + + + + https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> diff --git a/src/connect.c b/src/connect.c index 3dc434d..304a56f 100644 --- a/src/connect.c +++ b/src/connect.c @@ -735,6 +735,35 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectInterfaceDefineXML(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *path = NULL; +const gchar *xml; +guint flags; + +g_variant_get(inArgs, "(&su)", &xml, &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +interface = virInterfaceDefineXML(connect->connection, xml, flags); +if (!interface) +return virtDBusUtilSetLastVirtError(error); + +path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + +*outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectListDomains(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1766,6 +1795,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetCPUModelNames", virtDBusConnectGetCPUModelNames }, { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, +{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, { "ListNodeDevices", virtDBusConnectListNodeDevices }, diff --git a/tests/test_connect.py b/tests/test_connect.py index 2299b8a..d21b366 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -84,6 +84,10 @@ class TestConnect(libvirttest.BaseTestClass): sysinfo = self.connect.GetSysinfo(0) assert isinstance(sysinfo, dbus.String) +def test_connect_interface_define_xml(self): +path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) +assert isinstance(path, dbus.ObjectPath) + def test_connect_list_networks(self): networks = self.connect.ListNetworks(0) assert isinstance(networks, dbus.Array) diff --git a/tests/xmldata.py b/tests/xmldata.py index 25bb089..a70bac1 100644 --- a/tests/xmldata.py +++ b/tests/xmldata.py @@ -12,6 +12,18 @@ minimal_domain_xml = ''' ''' +minimal_interface_xml = ''' + + + + + + + + + +''' + minimal_network_xml = ''' bar -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 07/17] Implement Undefine method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 4 src/interface.c| 21 + tests/test_interface.py| 5 + 3 files changed, 30 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index f5ec281..4534b97 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -13,5 +13,9 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine"/> + diff --git a/src/interface.c b/src/interface.c index 077b10d..a2d1cef 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,26 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +if (virInterfaceUndefine(interface) < 0) +virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; @@ -77,6 +97,7 @@ static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, { "Destroy", virtDBusInterfaceDestroy }, +{ "Undefine", virtDBusInterfaceUndefine }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index 62fd517..4a83672 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -7,6 +7,11 @@ class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """ +def test_interface_undefine(self): +_,interface_obj = self.interface_create() +interface_obj.Destroy(0) +interface_obj.Undefine(0) + def test_interface_destroy(self): _,interface_obj = self.interface_create() interface_obj.Destroy(0) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 14/17] Implement InterfaceChangeCommit method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 5 + src/connect.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 604afea..8c88cc8 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -153,6 +153,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeBegin"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeCommit"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 0e19e91..2acc657 100644 --- a/src/connect.c +++ b/src/connect.c @@ -756,6 +756,27 @@ virtDBusConnectInterfaceChangeBegin(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusConnectInterfaceChangeCommit(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virInterfaceChangeCommit(connect->connection, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1854,6 +1875,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, +{ "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 05/17] Introduce Interface Tests & Test Create method for Interface Interface
Signed-off-by: Anya Harter --- tests/Makefile.am | 1 + tests/libvirttest.py| 12 tests/test_interface.py | 16 3 files changed, 29 insertions(+) create mode 100755 tests/test_interface.py diff --git a/tests/Makefile.am b/tests/Makefile.am index 09c3e2e..cd1fbd7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ test_helpers = \ test_programs = \ test_connect.py \ test_domain.py \ + test_interface.py \ test_network.py \ test_nodedev.py \ test_storage.py \ diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 3741abd..2a09182 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -71,6 +71,18 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() +def interface_create(self): +""" Fixture to define dummy interface on the test driver + +This fixture should be used in the setup of every test manipulating +with interfaces. +""" +path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) +obj = self.bus.get_object('org.libvirt', path) +interface_obj = dbus.Interface(obj, 'org.libvirt.Interface') +interface_obj.Create(0) +return path, interface_obj + @pytest.fixture def node_device_create(self): """ Fixture to create dummy node device on the test driver diff --git a/tests/test_interface.py b/tests/test_interface.py new file mode 100755 index 000..88be5dc --- /dev/null +++ b/tests/test_interface.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import dbus +import libvirttest + +class TestInterface(libvirttest.BaseTestClass): +""" Tests for methods and properties of the Interface interface +""" + +def test_interface_create(self): +_,interface_obj = self.interface_create() +interface_obj.Destroy(0) +interface_obj.Create(0) + +if __name__ == '__main__': +libvirttest.run() -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 12/17] Implement ListInterfaces method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 6 ++ src/connect.c| 38 2 files changed, 44 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index f690bab..791e1f5 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -161,6 +161,12 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virConnectListAllInterfaces"/> + + + https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListAllNetworks"/> diff --git a/src/connect.c b/src/connect.c index 304a56f..9be8264 100644 --- a/src/connect.c +++ b/src/connect.c @@ -801,6 +801,43 @@ virtDBusConnectListDomains(GVariant *inArgs, *outArgs = g_variant_new_tuple(&gdomains, 1); } +static void +virtDBusConnectListInterfaces(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterfacePtr) interfaces = NULL; +guint flags; +GVariantBuilder builder; +GVariant *ginterfaces; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virConnectListAllInterfaces(connect->connection, &interfaces, flags) < 0) +return virtDBusUtilSetLastVirtError(error); + +g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + +for (gint i = 0; interfaces[i]; i++) { +g_autofree gchar *path = NULL; +path = virtDBusUtilBusPathForVirInterface(interfaces[i], + connect->interfacePath); + +g_variant_builder_add(&builder, "o", path); +} + +ginterfaces = g_variant_builder_end(&builder); +*outArgs = g_variant_new_tuple(&ginterfaces, 1); +} + static void virtDBusConnectListNetworks(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1797,6 +1834,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, +{ "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, { "ListNodeDevices", virtDBusConnectListNodeDevices }, { "ListNWFilters", virtDBusConnectListNWFilters }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 03/17] Implement Create method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 src/interface.c| 45 ++ 2 files changed, 50 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 93fa32f..d98a646 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,5 +3,10 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> + + diff --git a/src/interface.c b/src/interface.c index 3c32f0f..4a5e431 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3,11 +3,56 @@ #include +static virInterfacePtr +virtDBusInterfaceGetVirInterface(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ +virInterfacePtr interface; + +if (virtDBusConnectOpen(connect, error) < 0) +return NULL; + +interface = virtDBusUtilVirInterfaceFromBusPath(connect->connection, +objectPath, +connect->interfacePath); +if (!interface) { +virtDBusUtilSetLastVirtError(error); +return NULL; +} + +return interface; +} + +static void +virtDBusInterfaceCreate(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath, +gpointer userData, +GVariant **outArgs G_GNUC_UNUSED, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +if (virInterfaceCreate(interface, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { +{ "Create", virtDBusInterfaceCreate }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 17/17] Implement InterfaceLookupByMAC method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 6 ++ src/connect.c| 29 + tests/test_connect.py| 1 + 3 files changed, 36 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index f99e205..3447538 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -170,6 +170,12 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByMACString"/> + + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/> diff --git a/src/connect.c b/src/connect.c index ae64d59..f0da1dd 100644 --- a/src/connect.c +++ b/src/connect.c @@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectInterfaceLookupByMAC(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath G_GNUC_UNUSED, +gpointer userData, +GVariant **outArgs, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *path = NULL; +const gchar *mac; + +g_variant_get(inArgs, "(&s)", &mac); + +if (!virtDBusConnectOpen(connect, NULL)) +return; + +interface = virInterfaceLookupByMACString(connect->connection, mac); +if (!interface) +return virtDBusUtilSetLastVirtError(error); + +path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + +*outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectInterfaceLookupByName(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1927,6 +1955,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, +{ "InterfaceLookupByMAC", virtDBusConnectInterfaceLookupByMAC }, { "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, diff --git a/tests/test_connect.py b/tests/test_connect.py index 7e33b2a..042c568 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -90,6 +90,7 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("InterfaceLookupByName", 'Name'), +("InterfaceLookupByMAC", 'MAC'), ]) def test_connect_interface_lookup_by_property(self, lookup_method_name, lookup_item): """Parameterized test for all InterfaceLookupBy* API calls of Connect interface -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 10/17] Implement MAC property for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 22 ++ tests/test_interface.py| 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index c53c110..921e07f 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,6 +3,11 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/> diff --git a/src/interface.c b/src/interface.c index a597fe5..4caafcf 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetMAC(const gchar *objectPath, +gpointer userData, +GVariant **value, +GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +const gchar *mac; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +mac = virInterfaceGetMACString(interface); +if (!mac) +return virtDBusUtilSetLastVirtError(error); + +*value = g_variant_new("s", mac); +} + static void virtDBusInterfaceGetName(const gchar *objectPath, gpointer userData, @@ -139,6 +160,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ "MAC", virtDBusInterfaceGetMAC, NULL }, { "Name", virtDBusInterfaceGetName, NULL }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index c11a9be..325f889 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -32,6 +32,7 @@ class TestInterface(libvirttest.BaseTestClass): obj = self.bus.get_object('org.libvirt', test_interface_path) props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) +assert isinstance(props['MAC'], dbus.String) if __name__ == '__main__': libvirttest.run() -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 06/17] Test Destroy method for Interface Interface
Signed-off-by: Anya Harter --- tests/test_interface.py | 4 1 file changed, 4 insertions(+) diff --git a/tests/test_interface.py b/tests/test_interface.py index 88be5dc..62fd517 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -7,6 +7,10 @@ class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """ +def test_interface_destroy(self): +_,interface_obj = self.interface_create() +interface_obj.Destroy(0) + def test_interface_create(self): _,interface_obj = self.interface_create() interface_obj.Destroy(0) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 04/17] Implement Destroy method for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 24 2 files changed, 29 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index d98a646..f5ec281 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -8,5 +8,10 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy"/> + + diff --git a/src/interface.c b/src/interface.c index 4a5e431..077b10d 100644 --- a/src/interface.c +++ b/src/interface.c @@ -47,12 +47,36 @@ virtDBusInterfaceCreate(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceDestroy(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +if (virInterfaceDestroy(interface, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { { 0 } }; static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = { { "Create", virtDBusInterfaceCreate }, +{ "Destroy", virtDBusInterfaceDestroy }, { 0 } }; -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 09/17] Implement Name property for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 22 ++ tests/test_interface.py| 8 3 files changed, 35 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index dc03258..c53c110 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,6 +3,11 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate"/> diff --git a/src/interface.c b/src/interface.c index fcec623..a597fe5 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +const gchar *name; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +name = virInterfaceGetName(interface); +if (!name) +return virtDBusUtilSetLastVirtError(error); + +*value = g_variant_new("s", name); +} + static void virtDBusInterfaceGetXMLDesc(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -118,6 +139,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ "Name", virtDBusInterfaceGetName, NULL }, { 0 } }; diff --git a/tests/test_interface.py b/tests/test_interface.py index 0b5a943..c11a9be 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -25,5 +25,13 @@ class TestInterface(libvirttest.BaseTestClass): _,interface_obj = self.interface_create() assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) +def test_interface_properties_type(self): +""" Ensure correct return type for Interface properties +""" +test_interface_path,_ = self.interface_create() +obj = self.bus.get_object('org.libvirt', test_interface_path) +props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE) +assert isinstance(props['Name'], dbus.String) + if __name__ == '__main__': libvirttest.run() -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 16/17] Implement InterfaceLookupByName method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 6 ++ src/connect.c| 29 + tests/test_connect.py| 12 3 files changed, 47 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 7c97117..f99e205 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -170,6 +170,12 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/> + + + https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains"/> diff --git a/src/connect.c b/src/connect.c index ebcfa38..ae64d59 100644 --- a/src/connect.c +++ b/src/connect.c @@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs, *outArgs = g_variant_new("(o)", path); } +static void +virtDBusConnectInterfaceLookupByName(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +g_autofree gchar *path = NULL; +const gchar *name; + +g_variant_get(inArgs, "(&s)", &name); + +if (!virtDBusConnectOpen(connect, NULL)) +return; + +interface = virInterfaceLookupByName(connect->connection, name); +if (!interface) +return virtDBusUtilSetLastVirtError(error); + +path = virtDBusUtilBusPathForVirInterface(interface, connect->interfacePath); + +*outArgs = g_variant_new("(o)", path); +} + static void virtDBusConnectListDomains(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1899,6 +1927,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, { "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, +{ "InterfaceLookupByName", virtDBusConnectInterfaceLookupByName }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, { "ListNetworks", virtDBusConnectListNetworks }, diff --git a/tests/test_connect.py b/tests/test_connect.py index d21b366..7e33b2a 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -88,6 +88,18 @@ class TestConnect(libvirttest.BaseTestClass): path = self.connect.InterfaceDefineXML(xmldata.minimal_interface_xml, 0) assert isinstance(path, dbus.ObjectPath) +@pytest.mark.parametrize("lookup_method_name,lookup_item", [ +("InterfaceLookupByName", 'Name'), +]) +def test_connect_interface_lookup_by_property(self, lookup_method_name, lookup_item): +"""Parameterized test for all InterfaceLookupBy* API calls of Connect interface +""" +original_path,_ = self.interface_create() +obj = self.bus.get_object('org.libvirt', original_path) +prop = obj.Get('org.libvirt.Interface', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE) +path = getattr(self.connect, lookup_method_name)(prop) +assert original_path == path + def test_connect_list_networks(self): networks = self.connect.ListNetworks(0) assert isinstance(networks, dbus.Array) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 15/17] Implement InterfaceChangeRollback method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 5 + src/connect.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 8c88cc8..7c97117 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -158,6 +158,11 @@ value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeCommit"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeRollback"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 2acc657..ebcfa38 100644 --- a/src/connect.c +++ b/src/connect.c @@ -777,6 +777,27 @@ virtDBusConnectInterfaceChangeCommit(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusConnectInterfaceChangeRollback(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ +virtDBusConnect *connect = userData; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virInterfaceChangeRollback(connect->connection, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1876,6 +1897,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, { "InterfaceChangeCommit", virtDBusConnectInterfaceChangeCommit }, +{ "InterfaceChangeRollback", virtDBusConnectInterfaceChangeRollback }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 11/17] Implement Active property for Interface Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Interface.xml | 5 + src/interface.c| 22 ++ tests/test_interface.py| 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml index 921e07f..6dd7c68 100644 --- a/data/org.libvirt.Interface.xml +++ b/data/org.libvirt.Interface.xml @@ -3,6 +3,11 @@ + + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive"/> + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/> diff --git a/src/interface.c b/src/interface.c index 4caafcf..191b8be 100644 --- a/src/interface.c +++ b/src/interface.c @@ -70,6 +70,27 @@ virtDBusInterfaceDestroy(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusInterfaceGetActive(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ +virtDBusConnect *connect = userData; +g_autoptr(virInterface) interface = NULL; +gint active; + +interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error); +if (!interface) +return; + +active = virInterfaceIsActive(interface); +if (active < 0) +return virtDBusUtilSetLastVirtError(error); + +*value = g_variant_new("b", !!active); +} + static void virtDBusInterfaceGetMAC(const gchar *objectPath, gpointer userData, @@ -160,6 +181,7 @@ virtDBusInterfaceUndefine(GVariant *inArgs G_GNUC_UNUSED, } static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = { +{ "Active", virtDBusInterfaceGetActive, NULL }, { "MAC", virtDBusInterfaceGetMAC, NULL }, { "Name", virtDBusInterfaceGetName, NULL }, { 0 } diff --git a/tests/test_interface.py b/tests/test_interface.py index 325f889..4c7e3fb 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -33,6 +33,7 @@ class TestInterface(libvirttest.BaseTestClass): props = obj.GetAll('org.libvirt.Interface', dbus_interface=dbus.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) assert isinstance(props['MAC'], dbus.String) +assert isinstance(props['Active'], dbus.Boolean) if __name__ == '__main__': libvirttest.run() -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH v2 13/17] Implement InterfaceChangeBegin method for Connect Interface
Signed-off-by: Anya Harter --- data/org.libvirt.Connect.xml | 5 + src/connect.c| 22 ++ 2 files changed, 27 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 791e1f5..604afea 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -148,6 +148,11 @@ + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceChangeBegin"/> + + https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDefineXML"/> diff --git a/src/connect.c b/src/connect.c index 9be8264..0e19e91 100644 --- a/src/connect.c +++ b/src/connect.c @@ -735,6 +735,27 @@ virtDBusConnectGetSysinfo(GVariant *inArgs, *outArgs = g_variant_new("(s)", sysinfo); } +static void +virtDBusConnectInterfaceChangeBegin(GVariant *inArgs, +GUnixFDList *inFDs G_GNUC_UNUSED, +const gchar *objectPath G_GNUC_UNUSED, +gpointer userData, +GVariant **outArgs G_GNUC_UNUSED, +GUnixFDList **outFDs G_GNUC_UNUSED, +GError **error) +{ +virtDBusConnect *connect = userData; +guint flags; + +g_variant_get(inArgs, "(u)", &flags); + +if (!virtDBusConnectOpen(connect, error)) +return; + +if (virInterfaceChangeBegin(connect->connection, flags) < 0) +virtDBusUtilSetLastVirtError(error); +} + static void virtDBusConnectInterfaceDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1832,6 +1853,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetCPUModelNames", virtDBusConnectGetCPUModelNames }, { "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities }, { "GetSysinfo", virtDBusConnectGetSysinfo }, +{ "InterfaceChangeBegin", virtDBusConnectInterfaceChangeBegin }, { "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML }, { "ListDomains", virtDBusConnectListDomains }, { "ListInterfaces", virtDBusConnectListInterfaces }, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [dbus PATCH] connect: fix calls to virtDBusConnectOpen
Signed-off-by: Anya Harter --- src/domain.c | 2 +- src/interface.c | 2 +- src/network.c | 2 +- src/nodedev.c | 2 +- src/nwfilter.c| 2 +- src/secret.c | 2 +- src/storagepool.c | 2 +- src/storagevol.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/domain.c b/src/domain.c index 5c5e6da..e8b1a0e 100644 --- a/src/domain.c +++ b/src/domain.c @@ -152,7 +152,7 @@ virtDBusDomainGetVirDomain(virtDBusConnect *connect, { virDomainPtr domain; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; domain = virtDBusUtilVirDomainFromBusPath(connect->connection, diff --git a/src/interface.c b/src/interface.c index 191b8be..6c24885 100644 --- a/src/interface.c +++ b/src/interface.c @@ -10,7 +10,7 @@ virtDBusInterfaceGetVirInterface(virtDBusConnect *connect, { virInterfacePtr interface; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; interface = virtDBusUtilVirInterfaceFromBusPath(connect->connection, diff --git a/src/network.c b/src/network.c index 3957ee6..f3d5472 100644 --- a/src/network.c +++ b/src/network.c @@ -21,7 +21,7 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect, { virNetworkPtr network; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; network = virtDBusUtilVirNetworkFromBusPath(connect->connection, diff --git a/src/nodedev.c b/src/nodedev.c index aa649c6..04fe29c 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -10,7 +10,7 @@ virtDBusNodeDeviceGetVirNodeDevice(virtDBusConnect *connect, { virNodeDevicePtr dev; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; dev = virtDBusUtilVirNodeDeviceFromBusPath(connect->connection, diff --git a/src/nwfilter.c b/src/nwfilter.c index 3fc6e12..d101778 100644 --- a/src/nwfilter.c +++ b/src/nwfilter.c @@ -10,7 +10,7 @@ virtDBusNWFilterGetVirNWFilter(virtDBusConnect *connect, { virNWFilterPtr nwfilter; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; nwfilter = virtDBusUtilVirNWFilterFromBusPath(connect->connection, diff --git a/src/secret.c b/src/secret.c index 903cfc2..85982f1 100644 --- a/src/secret.c +++ b/src/secret.c @@ -10,7 +10,7 @@ virtDBusSecretGetVirSecret(virtDBusConnect *connect, { virSecretPtr secret; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; secret = virtDBusUtilVirSecretFromBusPath(connect->connection, diff --git a/src/storagepool.c b/src/storagepool.c index 6eb6f27..b4d4f93 100644 --- a/src/storagepool.c +++ b/src/storagepool.c @@ -10,7 +10,7 @@ virtDBusStoragePoolGetVirStoragePool(virtDBusConnect *connect, { virStoragePoolPtr storagePool; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; storagePool = virtDBusUtilVirStoragePoolFromBusPath(connect->connection, diff --git a/src/storagevol.c b/src/storagevol.c index e5d1686..6ddff47 100644 --- a/src/storagevol.c +++ b/src/storagevol.c @@ -10,7 +10,7 @@ virtDBusStorageVolGetVirStorageVol(virtDBusConnect *connect, { virStorageVolPtr storageVol; -if (virtDBusConnectOpen(connect, error) < 0) +if (!virtDBusConnectOpen(connect, error)) return NULL; storageVol = virtDBusUtilVirStorageVolFromBusPath(connect->connection, -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] conf: rename Match functions
to be the vir prefix and interface name followed by ObjMatch ex. for virNetworkObjListExport, the match function is named virNetworkObjMatch Signed-off-by: Anya Harter --- src/conf/virnetworkobj.c| 6 +++--- src/conf/virnodedeviceobj.c | 4 ++-- src/conf/virsecretobj.c | 4 ++-- src/conf/virstorageobj.c| 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index c8939460a3..48d4ffecce 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1272,7 +1272,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, #define MATCH(FLAG) (flags & (FLAG)) static bool -virNetworkMatch(virNetworkObjPtr obj, +virNetworkObjMatch(virNetworkObjPtr obj, unsigned int flags) { /* filter by active state */ @@ -1331,7 +1331,7 @@ virNetworkObjListExportCallback(void *payload, !data->filter(data->conn, obj->def)) goto cleanup; -if (!virNetworkMatch(obj, data->flags)) +if (!virNetworkObjMatch(obj, data->flags)) goto cleanup; if (!data->nets) { @@ -1547,7 +1547,7 @@ virNetworkObjListPruneHelper(const void *payload, int want = 0; virObjectLock(obj); -want = virNetworkMatch(obj, data->flags); +want = virNetworkObjMatch(obj, data->flags); virObjectUnlock(obj); return want; } diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 6c04caf6ab..f6d940905c 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -804,7 +804,7 @@ virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr devs, #define MATCH(FLAG) ((flags & (VIR_CONNECT_LIST_NODE_DEVICES_CAP_ ## FLAG)) && \ virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_ ## FLAG)) static bool -virNodeDeviceMatch(virNodeDeviceObjPtr obj, +virNodeDeviceObjMatch(virNodeDeviceObjPtr obj, unsigned int flags) { /* Refresh the capabilities first, e.g. due to a driver change */ @@ -864,7 +864,7 @@ virNodeDeviceObjListExportCallback(void *payload, def = obj->def; if ((!data->filter || data->filter(data->conn, def)) && -virNodeDeviceMatch(obj, data->flags)) { +virNodeDeviceObjMatch(obj, data->flags)) { if (data->devices) { if (!(device = virGetNodeDevice(data->conn, def->name)) || VIR_STRDUP(device->parentName, def->parent) < 0) { diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index ba360810f4..f1a22c5d6c 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -500,7 +500,7 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secrets, #define MATCH(FLAG) (flags & (FLAG)) static bool -virSecretObjMatchFlags(virSecretObjPtr obj, +virSecretObjMatch(virSecretObjPtr obj, unsigned int flags) { virSecretDefPtr def = obj->def; @@ -554,7 +554,7 @@ virSecretObjListExportCallback(void *payload, if (data->filter && !data->filter(data->conn, def)) goto cleanup; -if (!virSecretObjMatchFlags(obj, data->flags)) +if (!virSecretObjMatch(obj, data->flags)) goto cleanup; if (!data->secrets) { diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 6b8a0fa58d..23a66e8dff 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1906,7 +1906,7 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr conn, #define MATCH(FLAG) (flags & (FLAG)) static bool -virStoragePoolMatch(virStoragePoolObjPtr obj, +virStoragePoolObjMatch(virStoragePoolObjPtr obj, unsigned int flags) { /* filter by active state */ @@ -1999,7 +1999,7 @@ virStoragePoolObjListExportCallback(void *payload, if (data->filter && !data->filter(data->conn, obj->def)) goto cleanup; -if (!virStoragePoolMatch(obj, data->flags)) +if (!virStoragePoolObjMatch(obj, data->flags)) goto cleanup; if (data->pools) { -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/3] conf: standardize naming
on vir*ObjListExport call stack Anya Harter (3): conf: rename structs used by Export function conf: rename Export Callback functions conf: rename Match functions src/conf/virinterfaceobj.c | 10 +- src/conf/virnetworkobj.c| 16 src/conf/virnodedeviceobj.c | 4 ++-- src/conf/virsecretobj.c | 10 +- src/conf/virstorageobj.c| 24 5 files changed, 32 insertions(+), 32 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] conf: rename structs used by Export function
to be the name of the Export function followed by Data ex. for virInterfaceObjListExport, the struct is named virInterfaceObjListExportData Signed-off-by: Anya Harter --- src/conf/virinterfaceobj.c | 6 +++--- src/conf/virnetworkobj.c | 6 +++--- src/conf/virsecretobj.c| 6 +++--- src/conf/virstorageobj.c | 12 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index b0c4ca15a1..10a291e911 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -260,7 +260,7 @@ virInterfaceObjMatch(virInterfaceObjPtr obj, #undef MATCH -struct virInterfaceObjListData { +struct virInterfaceObjListExportData { virConnectPtr conn; virInterfacePtr *ifaces; virInterfaceObjListFilter filter; @@ -274,7 +274,7 @@ virInterfaceObjListPopulate(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { -struct virInterfaceObjListData *data = opaque; +struct virInterfaceObjListExportData *data = opaque; virInterfaceObjPtr obj = payload; virInterfacePtr iface = NULL; @@ -316,7 +316,7 @@ virInterfaceObjListExport(virConnectPtr conn, unsigned int flags) { int ret = -1; -struct virInterfaceObjListData data = { +struct virInterfaceObjListExportData data = { .conn = conn, .ifaces = NULL, .filter = filter, .flags = flags, .nifaces = 0, .error = false }; diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index e00c8a7f6c..cc55b4806d 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1304,7 +1304,7 @@ virNetworkMatch(virNetworkObjPtr obj, #undef MATCH -struct virNetworkObjListData { +struct virNetworkObjListExportData { virConnectPtr conn; virNetworkPtr *nets; virNetworkObjListFilter filter; @@ -1318,7 +1318,7 @@ virNetworkObjListPopulate(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { -struct virNetworkObjListData *data = opaque; +struct virNetworkObjListExportData *data = opaque; virNetworkObjPtr obj = payload; virNetworkPtr net = NULL; @@ -1360,7 +1360,7 @@ virNetworkObjListExport(virConnectPtr conn, unsigned int flags) { int ret = -1; -struct virNetworkObjListData data = { +struct virNetworkObjListExportData data = { .conn = conn, .nets = NULL, .filter = filter, .flags = flags, .nnets = 0, .error = false }; diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 48ce3c8141..ba360810f4 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -526,7 +526,7 @@ virSecretObjMatchFlags(virSecretObjPtr obj, #undef MATCH -struct virSecretObjListData { +struct virSecretObjListExportData { virConnectPtr conn; virSecretPtr *secrets; virSecretObjListACLFilter filter; @@ -540,7 +540,7 @@ virSecretObjListExportCallback(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { -struct virSecretObjListData *data = opaque; +struct virSecretObjListExportData *data = opaque; virSecretObjPtr obj = payload; virSecretDefPtr def; virSecretPtr secret = NULL; @@ -584,7 +584,7 @@ virSecretObjListExport(virConnectPtr conn, virSecretObjListACLFilter filter, unsigned int flags) { -struct virSecretObjListData data = { +struct virSecretObjListExportData data = { .conn = conn, .secrets = NULL, .filter = filter, .flags = flags, .nsecrets = 0, .error = false }; diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index e66b2ebfb2..bbf707f2f9 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -960,7 +960,7 @@ virStoragePoolObjVolumeGetNames(virStoragePoolObjPtr obj, } -struct _virStorageVolObjExportData { +struct virStoragePoolObjVolumeListExportData { virConnectPtr conn; virStoragePoolVolumeACLFilter filter; virStoragePoolDefPtr pooldef; @@ -975,7 +975,7 @@ virStoragePoolObjVolumeListExportCb(void *payload, void *opaque) { virStorageVolObjPtr volobj = payload; -struct _virStorageVolObjExportData *data = opaque; +struct virStoragePoolObjVolumeListExportData *data = opaque; virStorageVolPtr vol = NULL; if (data->error) @@ -1012,7 +1012,7 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn, virStoragePoolVolumeACLFilter filter) { virStorageVolObjListPtr volumes = obj->volumes; -struct _virStorageVolObjExportData data = { +struct virStoragePoolObjVolumeListExportData data = { .conn = conn, .filter = filter, .pooldef = obj->def, .error = false, .nvols = 0, .vo
[libvirt] [PATCH 2/3] conf: rename Export Callback functions
to be the name of the export function followed by Callback ex. for virInterfaceObjListExport, the callback function is named virInterfaceObjListExportCallback Signed-off-by: Anya Harter --- src/conf/virinterfaceobj.c | 4 ++-- src/conf/virnetworkobj.c | 4 ++-- src/conf/virstorageobj.c | 8 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 10a291e911..670909decb 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -270,7 +270,7 @@ struct virInterfaceObjListExportData { }; static int -virInterfaceObjListPopulate(void *payload, +virInterfaceObjListExportCallback(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { @@ -325,7 +325,7 @@ virInterfaceObjListExport(virConnectPtr conn, virHashSize(ifaceobjs->objsName) + 1) < 0) goto cleanup; -virHashForEach(ifaceobjs->objsName, virInterfaceObjListPopulate, &data); +virHashForEach(ifaceobjs->objsName, virInterfaceObjListExportCallback, &data); if (data.error) goto cleanup; diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index cc55b4806d..c8939460a3 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1314,7 +1314,7 @@ struct virNetworkObjListExportData { }; static int -virNetworkObjListPopulate(void *payload, +virNetworkObjListExportCallback(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { @@ -1368,7 +1368,7 @@ virNetworkObjListExport(virConnectPtr conn, if (nets && VIR_ALLOC_N(data.nets, virHashSize(netobjs->objs) + 1) < 0) goto cleanup; -virHashForEach(netobjs->objs, virNetworkObjListPopulate, &data); +virHashForEach(netobjs->objs, virNetworkObjListExportCallback, &data); if (data.error) goto cleanup; diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index bbf707f2f9..6b8a0fa58d 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -970,7 +970,7 @@ struct virStoragePoolObjVolumeListExportData { }; static int -virStoragePoolObjVolumeListExportCb(void *payload, +virStoragePoolObjVolumeListExportCallback(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { @@ -1029,7 +1029,7 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn, return -1; } -virHashForEach(volumes->objsName, virStoragePoolObjVolumeListExportCb, &data); +virHashForEach(volumes->objsName, virStoragePoolObjVolumeListExportCallback, &data); virObjectRWUnlock(volumes); if (data.error) @@ -1983,7 +1983,7 @@ struct virStoragePoolObjListExportData { static int -virStoragePoolObjListExportCb(void *payload, +virStoragePoolObjListExportCallback(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { @@ -2035,7 +2035,7 @@ virStoragePoolObjListExport(virConnectPtr conn, if (pools && VIR_ALLOC_N(data.pools, virHashSize(poolobjs->objs) + 1) < 0) goto error; -virHashForEach(poolobjs->objs, virStoragePoolObjListExportCb, &data); +virHashForEach(poolobjs->objs, virStoragePoolObjListExportCallback, &data); virObjectRWUnlock(poolobjs); if (data.error) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 0/3] conf: standardize naming
on vir*ObjListExport call stack Anya Harter (3): conf: rename structs used by Export function conf: rename Export Callback functions conf: rename Match functions src/conf/virinterfaceobj.c | 16 +--- src/conf/virnetworkobj.c| 24 --- src/conf/virnodedeviceobj.c | 14 -- src/conf/virsecretobj.c | 14 -- src/conf/virstorageobj.c| 38 - 5 files changed, 59 insertions(+), 47 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 3/3] conf: rename Match functions
name match functions to be the vir prefix and interface name followed by ObjMatch ex. for virNetworkObjListExport, the match function is named virNetworkObjMatch Signed-off-by: Anya Harter --- src/conf/virnetworkobj.c| 8 src/conf/virnodedeviceobj.c | 6 +++--- src/conf/virsecretobj.c | 6 +++--- src/conf/virstorageobj.c| 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 69465d7f44..75a48601fa 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1272,8 +1272,8 @@ virNetworkObjUpdate(virNetworkObjPtr obj, #define MATCH(FLAG) (flags & (FLAG)) static bool -virNetworkMatch(virNetworkObjPtr obj, -unsigned int flags) +virNetworkObjMatch(virNetworkObjPtr obj, + unsigned int flags) { /* filter by active state */ if (MATCH(VIR_CONNECT_LIST_NETWORKS_FILTERS_ACTIVE) && @@ -1333,7 +1333,7 @@ virNetworkObjListExportCallback(void *payload, !data->filter(data->conn, obj->def)) goto cleanup; -if (!virNetworkMatch(obj, data->flags)) +if (!virNetworkObjMatch(obj, data->flags)) goto cleanup; if (!data->nets) { @@ -1549,7 +1549,7 @@ virNetworkObjListPruneHelper(const void *payload, int want = 0; virObjectLock(obj); -want = virNetworkMatch(obj, data->flags); +want = virNetworkObjMatch(obj, data->flags); virObjectUnlock(obj); return want; } diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 2c660a080a..c8ad1314b5 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -804,8 +804,8 @@ virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr devs, #define MATCH(FLAG) ((flags & (VIR_CONNECT_LIST_NODE_DEVICES_CAP_ ## FLAG)) && \ virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_ ## FLAG)) static bool -virNodeDeviceMatch(virNodeDeviceObjPtr obj, - unsigned int flags) +virNodeDeviceObjMatch(virNodeDeviceObjPtr obj, + unsigned int flags) { /* Refresh the capabilities first, e.g. due to a driver change */ if (!obj->skipUpdateCaps && @@ -866,7 +866,7 @@ virNodeDeviceObjListExportCallback(void *payload, def = obj->def; if ((!data->filter || data->filter(data->conn, def)) && -virNodeDeviceMatch(obj, data->flags)) { +virNodeDeviceObjMatch(obj, data->flags)) { if (data->devices) { if (!(device = virGetNodeDevice(data->conn, def->name)) || VIR_STRDUP(device->parentName, def->parent) < 0) { diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index c80cf364c6..2ff2998c15 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -500,8 +500,8 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secrets, #define MATCH(FLAG) (flags & (FLAG)) static bool -virSecretObjMatchFlags(virSecretObjPtr obj, - unsigned int flags) +virSecretObjMatch(virSecretObjPtr obj, + unsigned int flags) { virSecretDefPtr def = obj->def; @@ -556,7 +556,7 @@ virSecretObjListExportCallback(void *payload, if (data->filter && !data->filter(data->conn, def)) goto cleanup; -if (!virSecretObjMatchFlags(obj, data->flags)) +if (!virSecretObjMatch(obj, data->flags)) goto cleanup; if (!data->secrets) { diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 02ed491b6f..b44ce99dd5 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1908,8 +1908,8 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr conn, #define MATCH(FLAG) (flags & (FLAG)) static bool -virStoragePoolMatch(virStoragePoolObjPtr obj, -unsigned int flags) +virStoragePoolObjMatch(virStoragePoolObjPtr obj, + unsigned int flags) { /* filter by active state */ if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) && @@ -2003,7 +2003,7 @@ virStoragePoolObjListExportCallback(void *payload, if (data->filter && !data->filter(data->conn, obj->def)) goto cleanup; -if (!virStoragePoolMatch(obj, data->flags)) +if (!virStoragePoolObjMatch(obj, data->flags)) goto cleanup; if (data->pools) { -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 2/3] conf: rename Export Callback functions
name functions to be the name of the export function followed by Callback ex. for virInterfaceObjListExport, the callback function is named virInterfaceObjListExportCallback Signed-off-by: Anya Harter --- src/conf/virinterfaceobj.c | 8 src/conf/virnetworkobj.c | 8 src/conf/virstorageobj.c | 16 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 0fe0042920..028d699b32 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -272,9 +272,9 @@ struct _virInterfaceObjListExportData { }; static int -virInterfaceObjListPopulate(void *payload, -const void *name ATTRIBUTE_UNUSED, -void *opaque) +virInterfaceObjListExportCallback(void *payload, + const void *name ATTRIBUTE_UNUSED, + void *opaque) { virInterfaceObjListExportDataPtr data = opaque; virInterfaceObjPtr obj = payload; @@ -327,7 +327,7 @@ virInterfaceObjListExport(virConnectPtr conn, virHashSize(ifaceobjs->objsName) + 1) < 0) goto cleanup; -virHashForEach(ifaceobjs->objsName, virInterfaceObjListPopulate, &data); +virHashForEach(ifaceobjs->objsName, virInterfaceObjListExportCallback, &data); if (data.error) goto cleanup; diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index f69ee0c2fa..69465d7f44 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1316,9 +1316,9 @@ struct _virNetworkObjListExportData { }; static int -virNetworkObjListPopulate(void *payload, - const void *name ATTRIBUTE_UNUSED, - void *opaque) +virNetworkObjListExportCallback(void *payload, +const void *name ATTRIBUTE_UNUSED, +void *opaque) { virNetworkObjListExportDataPtr data = opaque; virNetworkObjPtr obj = payload; @@ -1370,7 +1370,7 @@ virNetworkObjListExport(virConnectPtr conn, if (nets && VIR_ALLOC_N(data.nets, virHashSize(netobjs->objs) + 1) < 0) goto cleanup; -virHashForEach(netobjs->objs, virNetworkObjListPopulate, &data); +virHashForEach(netobjs->objs, virNetworkObjListExportCallback, &data); if (data.error) goto cleanup; diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 0964088fda..02ed491b6f 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -972,9 +972,9 @@ struct _virStoragePoolObjVolumeListExportData { }; static int -virStoragePoolObjVolumeListExportCb(void *payload, -const void *name ATTRIBUTE_UNUSED, -void *opaque) +virStoragePoolObjVolumeListExportCallback(void *payload, + const void *name ATTRIBUTE_UNUSED, + void *opaque) { virStorageVolObjPtr volobj = payload; virStoragePoolObjVolumeListExportDataPtr data = opaque; @@ -1031,7 +1031,7 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn, return -1; } -virHashForEach(volumes->objsName, virStoragePoolObjVolumeListExportCb, &data); +virHashForEach(volumes->objsName, virStoragePoolObjVolumeListExportCallback, &data); virObjectRWUnlock(volumes); if (data.error) @@ -1987,9 +1987,9 @@ struct _virStoragePoolObjListExportData { static int -virStoragePoolObjListExportCb(void *payload, - const void *name ATTRIBUTE_UNUSED, - void *opaque) +virStoragePoolObjListExportCallback(void *payload, +const void *name ATTRIBUTE_UNUSED, +void *opaque) { virStoragePoolObjPtr obj = payload; virStoragePoolObjListExportDataPtr data = opaque; @@ -2039,7 +2039,7 @@ virStoragePoolObjListExport(virConnectPtr conn, if (pools && VIR_ALLOC_N(data.pools, virHashSize(poolobjs->objs) + 1) < 0) goto error; -virHashForEach(poolobjs->objs, virStoragePoolObjListExportCb, &data); +virHashForEach(poolobjs->objs, virStoragePoolObjListExportCallback, &data); virObjectRWUnlock(poolobjs); if (data.error) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/3] conf: rename structs used by Export function
name structs to be the name of the Export function followed by Data also tweak definitions to follow standard struct definition pattern ex. for virInterfaceObjListExport, the struct is defined as follows: typedef struct _virInterfaceObjListExportData virInterfaceObjListExportData; typedef virInterfaceObjListExportData *virInterfaceObjListExportDataPtr; struct _virInterfaceObjListExportData {...}; Signed-off-by: Anya Harter --- src/conf/virinterfaceobj.c | 8 +--- src/conf/virnetworkobj.c| 8 +--- src/conf/virnodedeviceobj.c | 8 +--- src/conf/virsecretobj.c | 8 +--- src/conf/virstorageobj.c| 16 ++-- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index b0c4ca15a1..0fe0042920 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -260,7 +260,9 @@ virInterfaceObjMatch(virInterfaceObjPtr obj, #undef MATCH -struct virInterfaceObjListData { +typedef struct _virInterfaceObjListExportData virInterfaceObjListExportData; +typedef virInterfaceObjListExportData *virInterfaceObjListExportDataPtr; +struct _virInterfaceObjListExportData { virConnectPtr conn; virInterfacePtr *ifaces; virInterfaceObjListFilter filter; @@ -274,7 +276,7 @@ virInterfaceObjListPopulate(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { -struct virInterfaceObjListData *data = opaque; +virInterfaceObjListExportDataPtr data = opaque; virInterfaceObjPtr obj = payload; virInterfacePtr iface = NULL; @@ -316,7 +318,7 @@ virInterfaceObjListExport(virConnectPtr conn, unsigned int flags) { int ret = -1; -struct virInterfaceObjListData data = { +virInterfaceObjListExportData data = { .conn = conn, .ifaces = NULL, .filter = filter, .flags = flags, .nifaces = 0, .error = false }; diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index e00c8a7f6c..f69ee0c2fa 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1304,7 +1304,9 @@ virNetworkMatch(virNetworkObjPtr obj, #undef MATCH -struct virNetworkObjListData { +typedef struct _virNetworkObjListExportData virNetworkObjListExportData; +typedef virNetworkObjListExportData *virNetworkObjListExportDataPtr; +struct _virNetworkObjListExportData { virConnectPtr conn; virNetworkPtr *nets; virNetworkObjListFilter filter; @@ -1318,7 +1320,7 @@ virNetworkObjListPopulate(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque) { -struct virNetworkObjListData *data = opaque; +virNetworkObjListExportDataPtr data = opaque; virNetworkObjPtr obj = payload; virNetworkPtr net = NULL; @@ -1360,7 +1362,7 @@ virNetworkObjListExport(virConnectPtr conn, unsigned int flags) { int ret = -1; -struct virNetworkObjListData data = { +virNetworkObjListExportData data = { .conn = conn, .nets = NULL, .filter = filter, .flags = flags, .nnets = 0, .error = false }; diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 6c04caf6ab..2c660a080a 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -838,7 +838,9 @@ virNodeDeviceMatch(virNodeDeviceObjPtr obj, #undef MATCH -struct virNodeDeviceObjListExportData { +typedef struct _virNodeDeviceObjListExportData virNodeDeviceObjListExportData; +typedef virNodeDeviceObjListExportData *virNodeDeviceObjListExportDataPtr; +struct _virNodeDeviceObjListExportData { virConnectPtr conn; virNodeDeviceObjListFilter filter; unsigned int flags; @@ -854,7 +856,7 @@ virNodeDeviceObjListExportCallback(void *payload, { virNodeDeviceObjPtr obj = payload; virNodeDeviceDefPtr def; -struct virNodeDeviceObjListExportData *data = opaque; +virNodeDeviceObjListExportDataPtr data = opaque; virNodeDevicePtr device = NULL; if (data->error) @@ -890,7 +892,7 @@ virNodeDeviceObjListExport(virConnectPtr conn, virNodeDeviceObjListFilter filter, unsigned int flags) { -struct virNodeDeviceObjListExportData data = { +virNodeDeviceObjListExportData data = { .conn = conn, .filter = filter, .flags = flags, .devices = NULL, .ndevices = 0, .error = false }; diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 48ce3c8141..c80cf364c6 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -526,7 +526,9 @@ virSecretObjMatchFlags(virSecretObjPtr obj, #undef MATCH -struct virSecretObjListData { +typedef struct _virSecretObjListExportData virSecretObjListExportData; +typedef virSecretObjListExportData *virSecretObjListExportDataPtr; +struct _virSecretObjListExportData { virConnectPtr c
[libvirt] [PATCH libvirt 2/3] events: move NULL check to EventStateQueueRemote
Remove NULL check from virObjectEventStateQueue and add NULL check to virObjectEventStateQueueRemote Remove NULL check around call to virObjectEventStateQueueRemote in remote_driver.c Signed-off-by: Anya Harter --- src/conf/object_event.c| 6 +++--- src/remote/remote_driver.c | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 826197000b..dd5c6ff32d 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -744,6 +744,9 @@ virObjectEventStateQueueRemote(virObjectEventStatePtr state, virObjectEventPtr event, int remoteID) { +if (!event) +return; + if (state->timer < 0) { virObjectUnref(event); return; @@ -776,9 +779,6 @@ void virObjectEventStateQueue(virObjectEventStatePtr state, virObjectEventPtr event) { - if (!event) - return; - virObjectEventStateQueueRemote(state, event, -1); } diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c22993ce9e..fbec5c727b 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -4435,8 +4435,7 @@ static void remoteEventQueue(struct private_data *priv, virObjectEventPtr event, int remoteID) { -if (event) -virObjectEventStateQueueRemote(priv->eventState, event, remoteID); +virObjectEventStateQueueRemote(priv->eventState, event, remoteID); } -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH libvirt 3/3] events: remove remoteEventQueue wrapper function
>From remote_driver.c And replace all calls with virObjectEventStateQueue such that: remoteEventQueue(priv, event, callbackID); becomes: virObjectEventStateQueue(priv->eventState, event, callbackID); Signed-off-by: Anya Harter --- src/remote/remote_driver.c | 74 +- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index fbec5c727b..c36941c27e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -4431,14 +4431,6 @@ remoteConnectDomainEventDeregister(virConnectPtr conn, } -static void -remoteEventQueue(struct private_data *priv, virObjectEventPtr event, - int remoteID) -{ -virObjectEventStateQueueRemote(priv->eventState, event, remoteID); -} - - static void remoteDomainBuildEventLifecycleHelper(virConnectPtr conn, remote_domain_event_lifecycle_msg *msg, @@ -4455,7 +4447,7 @@ remoteDomainBuildEventLifecycleHelper(virConnectPtr conn, event = virDomainEventLifecycleNewFromDom(dom, msg->event, msg->detail); virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4493,7 +4485,7 @@ remoteDomainBuildEventRebootHelper(virConnectPtr conn, event = virDomainEventRebootNewFromDom(dom); virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventReboot(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4530,7 +4522,7 @@ remoteDomainBuildEventRTCChangeHelper(virConnectPtr conn, event = virDomainEventRTCChangeNewFromDom(dom, msg->offset); virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventRTCChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4567,7 +4559,7 @@ remoteDomainBuildEventWatchdogHelper(virConnectPtr conn, event = virDomainEventWatchdogNewFromDom(dom, msg->action); virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventWatchdog(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4607,7 +4599,7 @@ remoteDomainBuildEventIOErrorHelper(virConnectPtr conn, msg->action); virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventIOError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4649,7 +4641,7 @@ remoteDomainBuildEventIOErrorReasonHelper(virConnectPtr conn, virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventIOErrorReason(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4688,7 +4680,7 @@ remoteDomainBuildEventBlockJobHelper(virConnectPtr conn, virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventBlockJob(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4728,7 +4720,7 @@ remoteDomainBuildEventBlockJob2(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, virObjectUnref(dom); -remoteEventQueue(priv, event, msg->callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, msg->callbackID); } static void @@ -4782,7 +4774,7 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr conn, virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); return; error: @@ -4843,7 +4835,7 @@ remoteDomainBuildEventControlErrorHelper(virConnectPtr conn, virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventControlError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4886,7 +4878,7 @@ remoteDomainBuildEventDiskChangeHelper(virConnectPtr conn, virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); } static void remoteDomainBuildEventDiskChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, @@ -4927,7 +4919,7 @@ remoteDomainBuildEventTrayChangeHelper(virConnectPtr conn, virObjectUnref(dom); -remoteEventQueue(priv, event, callbackID); +vir
[libvirt] [PATCH libvirt 0/3] events: clean up NULL checking involving virObjectEventStateQueueRemote
Currently, all virObjectEventStateQueue callers and virObjectEventStateQueueRemote callers need to do NULL checking. In this patch series, all NULL checking has been moved to virObjectEventStateQueueRemote and all callers of the Remote or not Remote function have their NULL checking removed. Anya Harter (3): events: add NULL check in virObjectEventStateQueue events: move NULL check to EventStateQueueRemote events: remove remoteEventQueue wrapper function src/bhyve/bhyve_driver.c | 15 ++ src/conf/object_event.c| 3 ++ src/lxc/lxc_driver.c | 24 -- src/lxc/lxc_process.c | 9 ++-- src/network/bridge_driver.c| 15 ++ src/node_device/node_device_udev.c | 6 +-- src/qemu/qemu_domain.c | 3 +- src/remote/remote_driver.c | 75 +- src/secret/secret_driver.c | 9 ++-- src/storage/storage_driver.c | 27 --- src/test/test_driver.c | 3 -- src/vz/vz_sdk.c| 3 +- 12 files changed, 73 insertions(+), 119 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH libvirt 1/3] events: add NULL check in virObjectEventStateQueue
And remove NULL checking from all callers Signed-off-by: Anya Harter --- src/bhyve/bhyve_driver.c | 15 +-- src/conf/object_event.c| 3 +++ src/lxc/lxc_driver.c | 24 src/lxc/lxc_process.c | 9 +++-- src/network/bridge_driver.c| 15 +-- src/node_device/node_device_udev.c | 6 ++ src/qemu/qemu_domain.c | 3 +-- src/secret/secret_driver.c | 9 +++-- src/storage/storage_driver.c | 27 +-- src/test/test_driver.c | 3 --- src/vz/vz_sdk.c| 3 +-- 11 files changed, 40 insertions(+), 77 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 97e8d4eb37..9284b51783 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -566,8 +566,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag virDomainDefFree(def); virDomainDefFree(oldDef); virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(privconn->domainEventState, event); +virObjectEventStateQueue(privconn->domainEventState, event); return dom; } @@ -616,8 +615,7 @@ bhyveDomainUndefine(virDomainPtr domain) cleanup: virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(privconn->domainEventState, event); +virObjectEventStateQueue(privconn->domainEventState, event); return ret; } @@ -896,8 +894,7 @@ bhyveDomainCreateWithFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(privconn->domainEventState, event); +virObjectEventStateQueue(privconn->domainEventState, event); return ret; } @@ -969,8 +966,7 @@ bhyveDomainCreateXML(virConnectPtr conn, virObjectUnref(caps); virDomainDefFree(def); virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(privconn->domainEventState, event); +virObjectEventStateQueue(privconn->domainEventState, event); return dom; } @@ -1002,8 +998,7 @@ bhyveDomainDestroy(virDomainPtr dom) cleanup: virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(privconn->domainEventState, event); +virObjectEventStateQueue(privconn->domainEventState, event); return ret; } diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 9a7e7e50c1..826197000b 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -776,6 +776,9 @@ void virObjectEventStateQueue(virObjectEventStatePtr state, virObjectEventPtr event) { + if (!event) + return; + virObjectEventStateQueueRemote(state, event, -1); } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a2e29a2121..cfb431488d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -499,8 +499,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) virDomainDefFree(def); virDomainDefFree(oldDef); virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(caps); virObjectUnref(cfg); return dom; @@ -553,8 +552,7 @@ static int lxcDomainUndefineFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -1132,8 +1130,7 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); virNWFilterUnlockFilterUpdates(); return ret; @@ -1260,8 +1257,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, cleanup: virDomainDefFree(def); virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(caps); virObjectUnref(cfg); virNWFilterUnlockFilterUpdates(); @@ -1516,8 +1512,7 @@ lxcDomainDestroyFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -if (event) -virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event); return ret; } @@ -1709,8 +1704,7 @@ static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque) virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_DEFINED,
Re: [libvirt] [PATCH libvirt 0/3] events: clean up NULL checking involving virObjectEventStateQueueRemote
On 06/12/2018 01:36 AM, Pavel Hrdina wrote: > On Mon, Jun 11, 2018 at 03:38:16PM -0400, Anya Harter wrote: >> Currently, all virObjectEventStateQueue callers and >> virObjectEventStateQueueRemote callers need to do NULL checking. >> >> In this patch series, all NULL checking has been moved to >> virObjectEventStateQueueRemote and all callers of the Remote or >> not Remote function have their NULL checking removed. >> >> Anya Harter (3): >> events: add NULL check in virObjectEventStateQueue >> events: move NULL check to EventStateQueueRemote >> events: remove remoteEventQueue wrapper function > > I've tweaked the commit messages and pushed it. Congratulation on your > first libvirt contribution! :) Thanks! > > One note, the same cleanup as for remote driver can be done for test > driver and the testObjectEventQueue() function. Yes, my intent is to repeat this cleanup with testObjectEventQueue, libxlDomainEventQueue, qemuDomainEventQueue, and umlDomainEventQueue. I was going to send the four as a patch series once they were done. This task was laid out on the BiteSizedTasks page https://wiki.libvirt.org/page/BiteSizedTasks#Remove_NULL_checking_around_EventStateQueue. > > Pavel > > > > -- > libvir-list mailing list > libvir-list@redhat.com > https://www.redhat.com/mailman/listinfo/libvir-list > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH libvirt 3/3] events: remove remoteEventQueue wrapper function
On 06/11/2018 03:38 PM, Anya Harter wrote: >>From remote_driver.c > > And replace all calls with virObjectEventStateQueue such that: > > remoteEventQueue(priv, event, callbackID); > > becomes: > > virObjectEventStateQueue(priv->eventState, event, callbackID); Just a quick edit... The last line of the commit message should read: virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > > Signed-off-by: Anya Harter > --- > src/remote/remote_driver.c | 74 +- > 1 file changed, 33 insertions(+), 41 deletions(-) > > diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c > index fbec5c727b..c36941c27e 100644 > --- a/src/remote/remote_driver.c > +++ b/src/remote/remote_driver.c > @@ -4431,14 +4431,6 @@ remoteConnectDomainEventDeregister(virConnectPtr conn, > } > > > -static void > -remoteEventQueue(struct private_data *priv, virObjectEventPtr event, > - int remoteID) > -{ > -virObjectEventStateQueueRemote(priv->eventState, event, remoteID); > -} > - > - > static void > remoteDomainBuildEventLifecycleHelper(virConnectPtr conn, >remote_domain_event_lifecycle_msg *msg, > @@ -4455,7 +4447,7 @@ remoteDomainBuildEventLifecycleHelper(virConnectPtr > conn, > event = virDomainEventLifecycleNewFromDom(dom, msg->event, msg->detail); > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, > @@ -4493,7 +4485,7 @@ remoteDomainBuildEventRebootHelper(virConnectPtr conn, > event = virDomainEventRebootNewFromDom(dom); > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventReboot(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, > @@ -4530,7 +4522,7 @@ remoteDomainBuildEventRTCChangeHelper(virConnectPtr > conn, > event = virDomainEventRTCChangeNewFromDom(dom, msg->offset); > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventRTCChange(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, > @@ -4567,7 +4559,7 @@ remoteDomainBuildEventWatchdogHelper(virConnectPtr conn, > event = virDomainEventWatchdogNewFromDom(dom, msg->action); > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventWatchdog(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, > @@ -4607,7 +4599,7 @@ remoteDomainBuildEventIOErrorHelper(virConnectPtr conn, > msg->action); > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventIOError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, > @@ -4649,7 +4641,7 @@ remoteDomainBuildEventIOErrorReasonHelper(virConnectPtr > conn, > > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventIOErrorReason(virNetClientProgramPtr prog > ATTRIBUTE_UNUSED, > @@ -4688,7 +4680,7 @@ remoteDomainBuildEventBlockJobHelper(virConnectPtr conn, > > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > } > static void > remoteDomainBuildEventBlockJob(virNetClientProgramPtr prog ATTRIBUTE_UNUSED, > @@ -4728,7 +4720,7 @@ remoteDomainBuildEventBlockJob2(virNetClientProgramPtr > prog ATTRIBUTE_UNUSED, > > virObjectUnref(dom); > > -remoteEventQueue(priv, event, msg->callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, msg->callbackID); > } > > static void > @@ -4782,7 +4774,7 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr conn, > > virObjectUnref(dom); > > -remoteEventQueue(priv, event, callbackID); > +virObjectEventStateQueueRemote(priv->eventState, event, callbackID); > return; > > error: > @@ -4843,7 +4835
[libvirt] [PATCH libvirt 3/4] events: remove qemuDomainEventQueue wrapper func
And replace all calls with virObjectEventStateQueue such that: qemuDomainEventQueue(driver, event); becomes: virObjectEventStateQueue(driver->domainEventState, event); And remove NULL checking from all callers. Signed-off-by: Anya Harter --- src/qemu/qemu_blockjob.c | 4 +- src/qemu/qemu_cgroup.c| 2 +- src/qemu/qemu_domain.c| 11 + src/qemu/qemu_domain.h| 2 - src/qemu/qemu_driver.c| 88 ++- src/qemu/qemu_hotplug.c | 26 ++-- src/qemu/qemu_migration.c | 24 +-- src/qemu/qemu_process.c | 54 8 files changed, 98 insertions(+), 113 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index e0dfb88c1c..b08e047490 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -210,8 +210,8 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver, "after block job", vm->def->name); } -qemuDomainEventQueue(driver, event); -qemuDomainEventQueue(driver, event2); +virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event2); virObjectUnref(cfg); } diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 43c5ae8f8e..c8fba7f9e6 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -896,7 +896,7 @@ qemuSetupCpuCgroup(virDomainObjPtr vm) event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams); } -qemuDomainEventQueue(priv->driver, event); +virObjectEventStateQueue(priv->driver->domainEventState, event); } return 0; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 756e938858..2119233907 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -256,13 +256,6 @@ qemuDomainDisableNamespace(virDomainObjPtr vm, } -void qemuDomainEventQueue(virQEMUDriverPtr driver, - virObjectEventPtr event) -{ -virObjectEventStateQueue(driver->domainEventState, event); -} - - void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver, virDomainObjPtr vm) @@ -283,7 +276,7 @@ qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver, } event = virDomainEventJobCompletedNewFromObj(vm, params, nparams); -qemuDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); } @@ -7872,7 +7865,7 @@ qemuDomainCheckRemoveOptionalDisk(virQEMUDriverPtr driver, virDomainDiskDefFree(disk); } -qemuDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f17157b951..fd8d9b5305 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -493,8 +493,6 @@ int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job, void qemuDomainEventFlush(int timer, void *opaque); -void qemuDomainEventQueue(virQEMUDriverPtr driver, - virObjectEventPtr event); void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver, virDomainObjPtr vm); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f0fb806fcd..7c79c324e6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -975,7 +975,7 @@ static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque) virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_DEFINED, VIR_DOMAIN_EVENT_DEFINED_ADDED); -qemuDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); } } @@ -1806,10 +1806,8 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn, cleanup: virDomainDefFree(def); virDomainObjEndAPI(&vm); -if (event) { -qemuDomainEventQueue(driver, event); -qemuDomainEventQueue(driver, event2); -} +virObjectEventStateQueue(driver->domainEventState, event); +virObjectEventStateQueue(driver->domainEventState, event2); virObjectUnref(caps); virNWFilterUnlockFilterUpdates(); return dom; @@ -1879,7 +1877,7 @@ static int qemuDomainSuspend(virDomainPtr dom) cleanup: virDomainObjEndAPI(&vm); -qemuDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -1942,7 +1940,7 @@ static int qemuDomainResume(virDomainPtr dom) cleanup: virDomainObjEndAPI(&vm); -qemuDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -2250,7 +2248,7 @@ qemuDomainDestroyFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -
[libvirt] [PATCH libvirt 0/4] rmv virObjectEventStateQueue wrapper funcs
Currently, there are four wrapper functions which call virObjectEventStateQueue: - testObjectEventQueue - libxlDomainEventQueue - qemuDomainEventQueue - umlDomainEventQueue This patch series removes these wrappers makes all calls directly to virObjectEventStateQueue. Since virObjectEventStateQueue takes care of NULL checking, all NULL checking by callers has also been removed. This patch series should complete the BiteSizedTask entry at https://wiki.libvirt.org/page/BiteSizedTasks#Remove_NULL_checking_around_EventStateQueue . Anya Harter (4): events: remove testObjectEventQueue wrapper func events: remove libxlDomainEventQueue wrapper func events: remove qemuDomainEventQueue wrapper func events: remove umlDomainEventQueue wrapper func src/libxl/libxl_domain.c| 24 +++--- src/libxl/libxl_domain.h| 4 -- src/libxl/libxl_driver.c| 21 +++-- src/libxl/libxl_migration.c | 18 +++- src/qemu/qemu_blockjob.c| 4 +- src/qemu/qemu_cgroup.c | 2 +- src/qemu/qemu_domain.c | 11 + src/qemu/qemu_domain.h | 2 - src/qemu/qemu_driver.c | 88 + src/qemu/qemu_hotplug.c | 26 +-- src/qemu/qemu_migration.c | 24 +- src/qemu/qemu_process.c | 54 +++ src/test/test_driver.c | 80 - src/uml/uml_driver.c| 33 -- 14 files changed, 162 insertions(+), 229 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH libvirt 1/4] events: remove testObjectEventQueue wrapper func
And replace all calls with virObjectEventStateQueue such that: testObjectEventQueue(privconn, event); becomes: virObjectEventStateQueue(privconn->eventState, event); Signed-off-by: Anya Harter --- src/test/test_driver.c | 80 +++--- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index eb4e5aa341..5494d51017 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -174,12 +174,6 @@ static void testDriverUnlock(testDriverPtr driver) virMutexUnlock(&driver->lock); } -static void testObjectEventQueue(testDriverPtr driver, - virObjectEventPtr event) -{ -virObjectEventStateQueue(driver->eventState, event); -} - #define TEST_NAMESPACE_HREF "http://libvirt.org/schemas/domain/test/1.0"; typedef struct _testDomainNamespaceDef testDomainNamespaceDef; @@ -1692,7 +1686,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, cleanup: virDomainObjEndAPI(&dom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); virDomainDefFree(def); testDriverUnlock(privconn); return ret; @@ -1791,7 +1785,7 @@ static int testDomainDestroyFlags(virDomainPtr domain, ret = 0; cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -1825,7 +1819,7 @@ static int testDomainResume(virDomainPtr domain) cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -1855,7 +1849,7 @@ static int testDomainSuspend(virDomainPtr domain) cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -1890,7 +1884,7 @@ static int testDomainShutdownFlags(virDomainPtr domain, ret = 0; cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -1958,7 +1952,7 @@ static int testDomainReboot(virDomainPtr domain, ret = 0; cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -2102,7 +2096,7 @@ testDomainSaveFlags(virDomainPtr domain, const char *path, unlink(path); } virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -2205,7 +2199,7 @@ testDomainRestoreFlags(virConnectPtr conn, VIR_FREE(xml); VIR_FORCE_CLOSE(fd); virDomainObjEndAPI(&dom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -2275,7 +2269,7 @@ static int testDomainCoreDumpWithFormat(virDomainPtr domain, cleanup: VIR_FORCE_CLOSE(fd); virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -2649,8 +2643,8 @@ testDomainRenameCallback(virDomainObjPtr privdom, cleanup: VIR_FREE(old_dom_name); VIR_FREE(new_dom_name); -testObjectEventQueue(driver, event_old); -testObjectEventQueue(driver, event_new); +virObjectEventStateQueue(driver->eventState, event_old); +virObjectEventStateQueue(driver->eventState, event_new); return ret; } @@ -2786,7 +2780,7 @@ static virDomainPtr testDomainDefineXMLFlags(virConnectPtr conn, virDomainDefFree(def); virDomainDefFree(oldDef); virDomainObjEndAPI(&dom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); return ret; } @@ -2840,7 +2834,7 @@ static int testDomainSetMetadata(virDomainPtr dom, if (ret == 0) { virObjectEventPtr ev = NULL; ev = virDomainEventMetadataChangeNewFromObj(privdom, type, uri); -testObjectEventQueue(privconn, ev); +virObjectEventStateQueue(privconn->eventState, ev); } virDomainObjEndAPI(&privdom); @@ -2995,7 +2989,7 @@ static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn->eventState, event); testDriverUnlock(privconn); return ret; } @@ -3061,7 +3055,7 @@ static int testDomainUndefineFlags(virDomainPtr domain, cleanup: virDomainObjEndAPI(&privdom); -testObjectEventQueue(privconn, event); +virObjectEventStateQueue(privconn
[libvirt] [PATCH libvirt 2/4] events: remove libxlDomainEventQueue wrapper func
And replace all calls with virObjectEventStateQueue such that: libxlDomainEventQueue(driver, event); becomes: virObjectEventStateQueue(driver->domainEventState, event); And remove NULL checking from all callers. Signed-off-by: Anya Harter --- src/libxl/libxl_domain.c| 24 ++-- src/libxl/libxl_domain.h| 4 src/libxl/libxl_driver.c| 21 +++-- src/libxl/libxl_migration.c | 18 ++ 4 files changed, 19 insertions(+), 48 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index d12b1b1b4b..2ab78ac9a5 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -526,10 +526,8 @@ libxlDomainShutdownThread(void *opaque) } destroy: -if (dom_event) { -libxlDomainEventQueue(driver, dom_event); -dom_event = NULL; -} +virObjectEventStateQueue(driver->domainEventState, dom_event); +dom_event = NULL; libxlDomainDestroyInternal(driver, vm); libxlDomainCleanup(driver, vm); if (!vm->persistent) @@ -538,10 +536,8 @@ libxlDomainShutdownThread(void *opaque) goto endjob; restart: -if (dom_event) { -libxlDomainEventQueue(driver, dom_event); -dom_event = NULL; -} +virObjectEventStateQueue(driver->domainEventState, dom_event); +dom_event = NULL; libxlDomainDestroyInternal(driver, vm); libxlDomainCleanup(driver, vm); if (libxlDomainStartNew(driver, vm, false) < 0) { @@ -554,8 +550,7 @@ libxlDomainShutdownThread(void *opaque) cleanup: virDomainObjEndAPI(&vm); -if (dom_event) -libxlDomainEventQueue(driver, dom_event); +virObjectEventStateQueue(driver->domainEventState, dom_event); libxl_event_free(cfg->ctx, ev); VIR_FREE(shutdown_info); virObjectUnref(cfg); @@ -616,12 +611,6 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event) VIR_FREE(shutdown_info); } -void -libxlDomainEventQueue(libxlDriverPrivatePtr driver, virObjectEventPtr event) -{ -virObjectEventStateQueue(driver->domainEventState, event); -} - char * libxlDomainManagedSavePath(libxlDriverPrivatePtr driver, virDomainObjPtr vm) { @@ -1394,8 +1383,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, restore_fd < 0 ? VIR_DOMAIN_EVENT_STARTED_BOOTED : VIR_DOMAIN_EVENT_STARTED_RESTORED); -if (event) -libxlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); ret = 0; goto cleanup; diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index b5b6332151..5d83230cd6 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -95,10 +95,6 @@ int libxlDomainJobUpdateTime(struct libxlDomainJobObj *job) ATTRIBUTE_RETURN_CHECK; -void -libxlDomainEventQueue(libxlDriverPrivatePtr driver, - virObjectEventPtr event); - char * libxlDomainManagedSavePath(libxlDriverPrivatePtr driver, virDomainObjPtr vm); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 8c40661e5a..5a5e792957 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1179,8 +1179,7 @@ libxlDomainSuspend(virDomainPtr dom) cleanup: virDomainObjEndAPI(&vm); -if (event) -libxlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -1234,8 +1233,7 @@ libxlDomainResume(virDomainPtr dom) cleanup: virDomainObjEndAPI(&vm); -if (event) -libxlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -1394,8 +1392,7 @@ libxlDomainDestroyFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -if (event) -libxlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -1734,8 +1731,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, VIR_FREE(xml); if (VIR_CLOSE(fd) < 0) virReportSystemError(errno, "%s", _("cannot close file")); -if (event) -libxlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -1950,8 +1946,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags) cleanup: virDomainObjEndAPI(&vm); -if (event) -libxlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; } @@ -2755,8 +2750,7 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
[libvirt] [PATCH libvirt 4/4] events: remove umlDomainEventQueue wrapper func
And replace all calls with virObjectEventStateQueue such that: umlDomainEventQueue(driver, event); becomes: virObjectEventStateQueue(driver->domainEventState, event); And remove NULL checking from all callers. Signed-off-by: Anya Harter --- src/uml/uml_driver.c | 33 - 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 53ec64e10f..0c5b7fcda7 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -125,8 +125,6 @@ static int umlOpenMonitor(struct uml_driver *driver, virDomainObjPtr vm); static int umlReadPidFile(struct uml_driver *driver, virDomainObjPtr vm); -static void umlDomainEventQueue(struct uml_driver *driver, -virObjectEventPtr event); static int umlStartVMDaemon(virConnectPtr conn, struct uml_driver *driver, @@ -228,8 +226,7 @@ umlAutostartDomain(virDomainObjPtr vm, virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED_BOOTED); -if (event) -umlDomainEventQueue(data->driver, event); +virObjectEventStateQueue(data->driver->domainEventState, event); } } virObjectUnlock(vm); @@ -425,10 +422,8 @@ umlInotifyEvent(int watch, } } virDomainObjEndAPI(&dom); -if (event) { -umlDomainEventQueue(driver, event); -event = NULL; -} +virObjectEventStateQueue(driver->domainEventState, event); +event = NULL; } cleanup: @@ -646,8 +641,7 @@ static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque) virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_DEFINED, VIR_DOMAIN_EVENT_DEFINED_ADDED); -if (event) -umlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); } } @@ -783,8 +777,7 @@ static int umlProcessAutoDestroyDom(void *payload, virDomainObjListRemove(data->driver->domains, dom); virDomainObjEndAPI(&dom); -if (event) -umlDomainEventQueue(data->driver, event); +virObjectEventStateQueue(data->driver->domainEventState, event); virHashRemoveEntry(data->driver->autodestroy, uuidstr); return 0; } @@ -1615,8 +1608,7 @@ static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml, cleanup: virDomainDefFree(def); virDomainObjEndAPI(&vm); -if (event) -umlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); umlDriverUnlock(driver); virNWFilterUnlockFilterUpdates(); return dom; @@ -1689,8 +1681,7 @@ umlDomainDestroyFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); -if (event) -umlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); umlDriverUnlock(driver); return ret; } @@ -1949,8 +1940,7 @@ static int umlDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) cleanup: virDomainObjEndAPI(&vm); -if (event) -umlDomainEventQueue(driver, event); +virObjectEventStateQueue(driver->domainEventState, event); umlDriverUnlock(driver); virNWFilterUnlockFilterUpdates(); return ret; @@ -2587,13 +2577,6 @@ umlConnectDomainEventDeregisterAny(virConnectPtr conn, } -/* driver must be locked before calling */ -static void umlDomainEventQueue(struct uml_driver *driver, -virObjectEventPtr event) -{ -virObjectEventStateQueue(driver->domainEventState, event); -} - static int umlConnectListAllDomains(virConnectPtr conn, virDomainPtr **domains, unsigned int flags) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] tests: add test file for smartcard database
Add test case explicitly defining a smartcard host certificates database via the following xml: /tmp/foo This case is not currently covered in the test suite. Signed-off-by: Anya Harter --- .../smartcard-host-certificates-database.args | 28 +++ .../smartcard-host-certificates-database.xml | 21 +++ tests/qemuxml2argvtest.c | 2 ++ .../smartcard-host-certificates-database.xml | 35 +++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 87 insertions(+) create mode 100644 tests/qemuxml2argvdata/smartcard-host-certificates-database.args create mode 100644 tests/qemuxml2argvdata/smartcard-host-certificates-database.xml create mode 100644 tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml diff --git a/tests/qemuxml2argvdata/smartcard-host-certificates-database.args b/tests/qemuxml2argvdata/smartcard-host-certificates-database.args new file mode 100644 index 00..bc159f234d --- /dev/null +++ b/tests/qemuxml2argvdata/smartcard-host-certificates-database.args @@ -0,0 +1,28 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot c \ +-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ +-usb \ +-device ccid-card-emulated,backend=certificates,cert1=cert1,cert2=cert2,\ +cert3=cert3,db=/tmp/foo,id=smartcard0,bus=ccid0.0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/smartcard-host-certificates-database.xml b/tests/qemuxml2argvdata/smartcard-host-certificates-database.xml new file mode 100644 index 00..fa35645736 --- /dev/null +++ b/tests/qemuxml2argvdata/smartcard-host-certificates-database.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + +hvm + + + +/usr/bin/qemu-system-i686 + + cert1 + cert2 + cert3 + /tmp/foo + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f44cac9fef..194a8d2bab 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1404,6 +1404,8 @@ mymain(void) QEMU_CAPS_CCID_EMULATED); DO_TEST("smartcard-host-certificates", QEMU_CAPS_CCID_EMULATED); +DO_TEST("smartcard-host-certificates-database", +QEMU_CAPS_CCID_EMULATED); DO_TEST("smartcard-passthrough-tcp", QEMU_CAPS_CCID_PASSTHRU); DO_TEST("smartcard-passthrough-spicevmc", diff --git a/tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml b/tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml new file mode 100644 index 00..55d54a4355 --- /dev/null +++ b/tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml @@ -0,0 +1,35 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + +hvm + + + + destroy + restart + destroy + +/usr/bin/qemu-system-i686 + + + + + + + cert1 + cert2 + cert3 + /tmp/foo + + + + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index f5805c7f50..4449954ad4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1163,6 +1163,7 @@ mymain(void) DO_TEST("smartcard-host", NONE); DO_TEST("smartcard-host-certificates", NONE); +DO_TEST("smartcard-host-certificates-database", NONE); DO_TEST("smartcard-passthrough-tcp", NONE); DO_TEST("smartcard-passthrough-spicevmc", NONE); DO_TEST("smartcard-controller", NONE); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/4] qemu: Escape commas for qemuBuildChrChardevFileStr
Add comma escaping for fileval. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 3 ++- tests/qemuxml2argvdata/name-escape.args | 2 ++ tests/qemuxml2argvdata/name-escape.xml | 4 tests/qemuxml2argvtest.c| 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b764008949..40e8f8fccf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4867,7 +4867,8 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManager, virBufferAsprintf(buf, ",%s=%s,%s=on", filearg, fdpath, appendarg); VIR_FREE(fdpath); } else { -virBufferAsprintf(buf, ",%s=%s", filearg, fileval); +virBufferAsprintf(buf, ",%s=", filearg); +virQEMUBuildBufferEscapeComma(buf, fileval); if (appendval != VIR_TRISTATE_SWITCH_ABSENT) { virBufferAsprintf(buf, ",%s=%s", appendarg, virTristateSwitchTypeToString(appendval)); diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index 4b03068f95..35a13b2533 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -25,6 +25,8 @@ bar=2/monitor.sock,server,nowait \ -usb \ -chardev tty,id=charserial0,path=/dev/ttyS2,,foo \ -device isa-serial,chardev=charserial0,id=serial0 \ +-chardev file,id=charserial1,path=/tmp/serial.log,,foo,append=on \ +-device isa-serial,chardev=charserial1,id=serial1 \ -chardev pipe,id=charchannel0,path=/tmp/guestfwd,,foo \ -netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \ -vnc unix:/tmp/lib/domain--1-foo=1,,bar=2/vnc.sock \ diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 3f5e1c9829..79c1b34458 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -23,6 +23,10 @@ + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c194ff59c9..3e02fa576c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2761,7 +2761,8 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX, -QEMU_CAPS_DEVICE_ISA_SERIAL); +QEMU_CAPS_DEVICE_ISA_SERIAL, +QEMU_CAPS_CHARDEV_FILE_APPEND); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/4] qemu: add comma escaping in qemu_command.c
The function virQEMUBuildBufferEscapeComma is used to escape commas in user provided fields for qemu command line processing in the four functions listed below. A corresponding test for each comma escaping instance has been added to tests/qemuxml2argvdata/name-escape.xml. This should complete the BiteSizedTask entry at https://wiki.libvirt.org/page/BiteSizedTasks#qemu:_Use_comma_escaping_for_more_command_line_values. Anya Harter (4): qemu: Escape commas for qemuBuildChrChardevStr qemu: Escape commas for qemuBuildChrChardevFileStr qemu: Escape commas for qemuBuildSmartcardCommandLine qemu: Escape commas for qemuBuildGrapicsSPICECommandLine src/qemu/qemu_command.c | 44 +++-- tests/qemuxml2argvdata/name-escape.args | 14 ++-- tests/qemuxml2argvdata/name-escape.xml | 18 ++ tests/qemuxml2argvtest.c| 10 +- 4 files changed, 58 insertions(+), 28 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/4] qemu: Escape commas for qemuBuildSmartcardCommandLine
Add comma escaping for smartcard->data.cert.file[i] and smartcard->data.cert.database. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 21 - tests/qemuxml2argvdata/name-escape.args | 3 +++ tests/qemuxml2argvdata/name-escape.xml | 6 ++ tests/qemuxml2argvtest.c| 3 ++- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 40e8f8fccf..a9a5e200e9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8716,29 +8716,16 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, virBufferAddLit(&opt, "ccid-card-emulated,backend=certificates"); for (i = 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) { -if (strchr(smartcard->data.cert.file[i], ',')) { -virBufferFreeAndReset(&opt); -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid certificate name: %s"), - smartcard->data.cert.file[i]); -return -1; -} -virBufferAsprintf(&opt, ",cert%zu=%s", i + 1, - smartcard->data.cert.file[i]); +virBufferAsprintf(&opt, ",cert%zu=", i + 1); +virQEMUBuildBufferEscapeComma(&opt, smartcard->data.cert.file[i]); } if (smartcard->data.cert.database) { -if (strchr(smartcard->data.cert.database, ',')) { -virBufferFreeAndReset(&opt); -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid database name: %s"), - smartcard->data.cert.database); -return -1; -} database = smartcard->data.cert.database; } else { database = VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE; } -virBufferAsprintf(&opt, ",db=%s", database); +virBufferAddLit(&opt, ",db="); +virQEMUBuildBufferEscapeComma(&opt, database); break; case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index 35a13b2533..d3b908a7e6 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -22,7 +22,10 @@ bar=2/monitor.sock,server,nowait \ -no-shutdown \ -no-acpi \ -boot c \ +-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ -usb \ +-device ccid-card-emulated,backend=certificates,cert1=cert1,,foo,cert2=cert2,\ +cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \ -chardev tty,id=charserial0,path=/dev/ttyS2,,foo \ -device isa-serial,chardev=charserial0,id=serial0 \ -chardev file,id=charserial1,path=/tmp/serial.log,,foo,append=on \ diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 79c1b34458..9ca7be5968 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -31,5 +31,11 @@ + + cert1,foo + cert2 + cert3 + /etc/pki/nssdb,foo + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3e02fa576c..7468537c68 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2762,7 +2762,8 @@ mymain(void) QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX, QEMU_CAPS_DEVICE_ISA_SERIAL, -QEMU_CAPS_CHARDEV_FILE_APPEND); +QEMU_CAPS_CHARDEV_FILE_APPEND, +QEMU_CAPS_CCID_EMULATED); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/4] qemu: Escape commas for qemuBuildGrapicsSPICECommandLine
Add comma escaping for cfg->spiceTLSx509certdir and graphics->data.spice.rendernode. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 11 --- tests/qemuxml2argvdata/name-escape.args | 5 +++-- tests/qemuxml2argvdata/name-escape.xml | 1 + tests/qemuxml2argvtest.c| 5 + 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a9a5e200e9..36dccea9b2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7974,8 +7974,11 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,"); -if (hasSecure) -virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir); +if (hasSecure) { +virBufferAddLit(&opt, "x509-dir="); +virQEMUBuildBufferEscapeComma(&opt, cfg->spiceTLSx509certdir); +virBufferAsprintf(&opt, ","); +} switch (graphics->data.spice.defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: @@ -8082,7 +8085,9 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, goto error; } -virBufferAsprintf(&opt, "rendernode=%s,", graphics->data.spice.rendernode); +virBufferAddLit(&opt, "rendernode="); +virQEMUBuildBufferEscapeComma(&opt, graphics->data.spice.rendernode); +virBufferAsprintf(&opt, ","); } } diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index d3b908a7e6..72ed2e8410 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -33,6 +33,7 @@ cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \ -chardev pipe,id=charchannel0,path=/tmp/guestfwd,,foo \ -netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \ -vnc unix:/tmp/lib/domain--1-foo=1,,bar=2/vnc.sock \ --spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock \ --vga cirrus \ +-spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock,gl=on,\ +rendernode=/dev/dri/foo,,bar \ +-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 9ca7be5968..0580de1813 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -19,6 +19,7 @@ + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7468537c68..ade21f5a10 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2761,6 +2761,11 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX, +QEMU_CAPS_DEVICE_VIRTIO_GPU, +QEMU_CAPS_VIRTIO_GPU_VIRGL, +QEMU_CAPS_SPICE_GL, +QEMU_CAPS_SPICE_RENDERNODE, +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_FILE_APPEND, QEMU_CAPS_CCID_EMULATED); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/4] qemu: Escape commas for qemuBuildChrChardevStr
Add comma escaping for dev->data.file.path in cases VIR_DOMAIN_CHR_TYPE_DEV and VIR_DOMAIN_CHR_TYPE_PIPE. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 9 + tests/qemuxml2argvdata/name-escape.args | 4 tests/qemuxml2argvdata/name-escape.xml | 7 +++ tests/qemuxml2argvtest.c| 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bb956a77f4..b764008949 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4975,9 +4975,10 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, break; case VIR_DOMAIN_CHR_TYPE_DEV: -virBufferAsprintf(&buf, "%s,id=%s,path=%s", +virBufferAsprintf(&buf, "%s,id=%s,path=", STRPREFIX(alias, "parallel") ? "parport" : "tty", - charAlias, dev->data.file.path); + charAlias); +virQEMUBuildBufferEscapeComma(&buf, dev->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_FILE: @@ -4997,8 +4998,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, break; case VIR_DOMAIN_CHR_TYPE_PIPE: -virBufferAsprintf(&buf, "pipe,id=%s,path=%s", charAlias, - dev->data.file.path); +virBufferAsprintf(&buf, "pipe,id=%s,path=", charAlias); +virQEMUBuildBufferEscapeComma(&buf, dev->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_STDIO: diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index 5ff8c03db8..4b03068f95 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -23,6 +23,10 @@ bar=2/monitor.sock,server,nowait \ -no-acpi \ -boot c \ -usb \ +-chardev tty,id=charserial0,path=/dev/ttyS2,,foo \ +-device isa-serial,chardev=charserial0,id=serial0 \ +-chardev pipe,id=charchannel0,path=/tmp/guestfwd,,foo \ +-netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \ -vnc unix:/tmp/lib/domain--1-foo=1,,bar=2/vnc.sock \ -spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock \ -vga cirrus \ diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 6b93d71798..3f5e1c9829 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -20,5 +20,12 @@ + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f44cac9fef..c194ff59c9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2760,7 +2760,8 @@ mymain(void) QEMU_CAPS_NAME_GUEST, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_SPICE, -QEMU_CAPS_SPICE_UNIX); +QEMU_CAPS_SPICE_UNIX, +QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list