[PATCH 2/4] qemu_command: Don't open code virPCIDeviceAddressAsString()

Michal Privoznik posted 4 patches 2 years, 2 months ago
[PATCH 2/4] qemu_command: Don't open code virPCIDeviceAddressAsString()
Posted by Michal Privoznik 2 years, 2 months ago
When building a hostdev props, its PCI address is formatted via
g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, ...); Well, we have a
function that does exactly that: virPCIDeviceAddressAsString().
Us the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_command.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d54149ed2d..23909dbbab 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4704,11 +4704,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
     g_autoptr(virJSONValue) props = NULL;
     virDomainHostdevSubsysPCI *pcisrc = &dev->source.subsys.u.pci;
     virDomainNetTeamingInfo *teaming;
-    g_autofree char *host = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT,
-                                            pcisrc->addr.domain,
-                                            pcisrc->addr.bus,
-                                            pcisrc->addr.slot,
-                                            pcisrc->addr.function);
+    g_autofree char *host = virPCIDeviceAddressAsString(&pcisrc->addr);
     const char *failover_pair_id = NULL;
 
     /* caller has to assign proper passthrough backend type */
-- 
2.41.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 2/4] qemu_command: Don't open code virPCIDeviceAddressAsString()
Posted by Jonathon Jongsma 2 years, 2 months ago
On 11/28/23 9:59 AM, Michal Privoznik wrote:
> When building a hostdev props, its PCI address is formatted via
> g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, ...); Well, we have a
> function that does exactly that: virPCIDeviceAddressAsString().
> Us the latter.

s/Us/Use/

> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>   src/qemu/qemu_command.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index d54149ed2d..23909dbbab 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -4704,11 +4704,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
>       g_autoptr(virJSONValue) props = NULL;
>       virDomainHostdevSubsysPCI *pcisrc = &dev->source.subsys.u.pci;
>       virDomainNetTeamingInfo *teaming;
> -    g_autofree char *host = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT,
> -                                            pcisrc->addr.domain,
> -                                            pcisrc->addr.bus,
> -                                            pcisrc->addr.slot,
> -                                            pcisrc->addr.function);
> +    g_autofree char *host = virPCIDeviceAddressAsString(&pcisrc->addr);
>       const char *failover_pair_id = NULL;
>   
>       /* caller has to assign proper passthrough backend type */
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org