* [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open()
@ 2024-07-15 8:21 Zhao Liu
2024-07-15 8:21 ` [PATCH 1/7] hw/i386/sgx: Get rid of qemu_open_old() Zhao Liu
` (6 more replies)
0 siblings, 7 replies; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu
Hi list,
After Daniel's renaming (448058aa99aa "util: rename qemu_open() to
qemu_open_old()"), I find some qemu_open_old() can be directly replaced
by the new qemu_open().
This series considers the case where @errp exists, for which @errp can
be passed directly to qemu_open().
There would be more cleanup to help qemu_open_old() retire as early as
possible.
Thanks and Best Regards,
Zhao
---
Zhao Liu (7):
hw/i386/sgx: Get rid of qemu_open_old()
hw/usb/host-libusb: Get rid of qemu_open_old()
hw/usb/u2f-passthru: Get rid of qemu_open_old()
hw/vfio/container: Get rid of qemu_open_old()
backends/hostmem-epc: Get rid of qemu_open_old()
backends/iommufd: Get rid of qemu_open_old()
backends/rng-random: Get rid of qemu_open_old()
backends/hostmem-epc.c | 4 +---
backends/iommufd.c | 3 +--
backends/rng-random.c | 9 +++++----
hw/i386/sgx.c | 6 ++++--
hw/usb/host-libusb.c | 3 +--
hw/usb/u2f-passthru.c | 4 +---
hw/vfio/container.c | 6 ++----
7 files changed, 15 insertions(+), 20 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/7] hw/i386/sgx: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 8:21 ` [PATCH 2/7] hw/usb/host-libusb: " Zhao Liu
` (5 subsequent siblings)
6 siblings, 0 replies; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu,
Paolo Bonzini, Richard Henderson, Eduardo Habkost,
Michael S. Tsirkin, Marcel Apfelbaum
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open(). And considering the SGX
enablement description is useful, convert it into a error message hint.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Eduardo Habkost <eduardo@habkost.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/i386/sgx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c
index de76397bcfb3..a14a84bc6f69 100644
--- a/hw/i386/sgx.c
+++ b/hw/i386/sgx.c
@@ -157,10 +157,12 @@ SGXInfo *qmp_query_sgx_capabilities(Error **errp)
{
SGXInfo *info = NULL;
uint32_t eax, ebx, ecx, edx;
+ Error *local_err = NULL;
- int fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
+ int fd = qemu_open("/dev/sgx_vepc", O_RDWR, &local_err);
if (fd < 0) {
- error_setg(errp, "SGX is not enabled in KVM");
+ error_append_hint(&local_err, "SGX is not enabled in KVM");
+ error_propagate(errp, local_err);
return NULL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/7] hw/usb/host-libusb: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
2024-07-15 8:21 ` [PATCH 1/7] hw/i386/sgx: Get rid of qemu_open_old() Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 9:44 ` Philippe Mathieu-Daudé
2024-07-15 8:21 ` [PATCH 3/7] hw/usb/u2f-passthru: " Zhao Liu
` (4 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open().
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/usb/host-libusb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 80122b41259a..691bc881fbcd 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1212,9 +1212,8 @@ static void usb_host_realize(USBDevice *udev, Error **errp)
if (s->hostdevice) {
int fd;
s->needs_autoscan = false;
- fd = qemu_open_old(s->hostdevice, O_RDWR);
+ fd = qemu_open(s->hostdevice, O_RDWR, errp);
if (fd < 0) {
- error_setg_errno(errp, errno, "failed to open %s", s->hostdevice);
return;
}
rc = usb_host_open(s, NULL, fd);
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/7] hw/usb/u2f-passthru: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
2024-07-15 8:21 ` [PATCH 1/7] hw/i386/sgx: Get rid of qemu_open_old() Zhao Liu
2024-07-15 8:21 ` [PATCH 2/7] hw/usb/host-libusb: " Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 9:44 ` Philippe Mathieu-Daudé
2024-07-15 8:21 ` [PATCH 4/7] hw/vfio/container: " Zhao Liu
` (3 subsequent siblings)
6 siblings, 1 reply; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open().
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/usb/u2f-passthru.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/usb/u2f-passthru.c b/hw/usb/u2f-passthru.c
index b7025d303d07..c4a783d12864 100644
--- a/hw/usb/u2f-passthru.c
+++ b/hw/usb/u2f-passthru.c
@@ -482,10 +482,8 @@ static void u2f_passthru_realize(U2FKeyState *base, Error **errp)
return;
#endif
} else {
- fd = qemu_open_old(key->hidraw, O_RDWR);
+ fd = qemu_open(key->hidraw, O_RDWR, errp);
if (fd < 0) {
- error_setg(errp, "%s: Failed to open %s", TYPE_U2F_PASSTHRU,
- key->hidraw);
return;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/7] hw/vfio/container: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
` (2 preceding siblings ...)
2024-07-15 8:21 ` [PATCH 3/7] hw/usb/u2f-passthru: " Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 9:46 ` Philippe Mathieu-Daudé
2024-07-16 13:43 ` Cédric Le Goater
2024-07-15 8:21 ` [PATCH 5/7] backends/hostmem-epc: " Zhao Liu
` (2 subsequent siblings)
6 siblings, 2 replies; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu,
Alex Williamson, Cédric Le Goater
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open().
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: "Cédric Le Goater" <clg@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/vfio/container.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index 425db1a14c07..38a9df34964a 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -600,9 +600,8 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
}
}
- fd = qemu_open_old("/dev/vfio/vfio", O_RDWR);
+ fd = qemu_open("/dev/vfio/vfio", O_RDWR, errp);
if (fd < 0) {
- error_setg_errno(errp, errno, "failed to open /dev/vfio/vfio");
goto put_space_exit;
}
@@ -743,9 +742,8 @@ static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
group = g_malloc0(sizeof(*group));
snprintf(path, sizeof(path), "/dev/vfio/%d", groupid);
- group->fd = qemu_open_old(path, O_RDWR);
+ group->fd = qemu_open(path, O_RDWR, errp);
if (group->fd < 0) {
- error_setg_errno(errp, errno, "failed to open %s", path);
goto free_group_exit;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/7] backends/hostmem-epc: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
` (3 preceding siblings ...)
2024-07-15 8:21 ` [PATCH 4/7] hw/vfio/container: " Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 9:45 ` Philippe Mathieu-Daudé
2024-07-15 14:02 ` Igor Mammedov
2024-07-15 8:21 ` [PATCH 6/7] backends/iommufd: " Zhao Liu
2024-07-15 8:21 ` [PATCH 7/7] backends/rng-random: " Zhao Liu
6 siblings, 2 replies; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu,
David Hildenbrand, Igor Mammedov
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open().
Cc: David Hildenbrand <david@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
backends/hostmem-epc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c
index f58fcf00a10b..6c024d6217d2 100644
--- a/backends/hostmem-epc.c
+++ b/backends/hostmem-epc.c
@@ -29,10 +29,8 @@ sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
return false;
}
- fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
+ fd = qemu_open("/dev/sgx_vepc", O_RDWR, errp);
if (fd < 0) {
- error_setg_errno(errp, errno,
- "failed to open /dev/sgx_vepc to alloc SGX EPC");
return false;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 6/7] backends/iommufd: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
` (4 preceding siblings ...)
2024-07-15 8:21 ` [PATCH 5/7] backends/hostmem-epc: " Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 9:45 ` Philippe Mathieu-Daudé
2024-07-16 8:10 ` Yi Liu
2024-07-15 8:21 ` [PATCH 7/7] backends/rng-random: " Zhao Liu
6 siblings, 2 replies; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu,
Yi Liu, Eric Auger, Zhenzhong Duan
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open().
Cc: Yi Liu <yi.l.liu@intel.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
backends/iommufd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/backends/iommufd.c b/backends/iommufd.c
index 84fefbc9ee7a..cabd1b50025d 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -77,9 +77,8 @@ bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp)
int fd;
if (be->owned && !be->users) {
- fd = qemu_open_old("/dev/iommu", O_RDWR);
+ fd = qemu_open("/dev/iommu", O_RDWR, errp);
if (fd < 0) {
- error_setg_errno(errp, errno, "/dev/iommu opening failed");
return false;
}
be->fd = fd;
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
` (5 preceding siblings ...)
2024-07-15 8:21 ` [PATCH 6/7] backends/iommufd: " Zhao Liu
@ 2024-07-15 8:21 ` Zhao Liu
2024-07-15 9:46 ` Philippe Mathieu-Daudé
6 siblings, 1 reply; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 8:21 UTC (permalink / raw)
To: Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Zhao Liu,
Laurent Vivier, Amit Shah
For qemu_open_old(), osdep.h said:
> Don't introduce new usage of this function, prefer the following
> qemu_open/qemu_create that take an "Error **errp".
So replace qemu_open_old() with qemu_open(). And considering
rng_random_opened() will lose its obvious error handling case after
removing error_setg_file_open(), add comment to remind here.
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Amit Shah <amit@kernel.org>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
backends/rng-random.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 80eb5be138ce..3cdb982533b5 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -75,10 +75,11 @@ static void rng_random_opened(RngBackend *b, Error **errp)
error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
"filename", "a valid filename");
} else {
- s->fd = qemu_open_old(s->filename, O_RDONLY | O_NONBLOCK);
- if (s->fd == -1) {
- error_setg_file_open(errp, errno, s->filename);
- }
+ /*
+ * Once the open fails, the error message is integrated into
+ * the *errp object by qemu_open().
+ */
+ s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK, errp);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/7] hw/usb/host-libusb: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 2/7] hw/usb/host-libusb: " Zhao Liu
@ 2024-07-15 9:44 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 9:44 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel
On 15/7/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> hw/usb/host-libusb.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/7] hw/usb/u2f-passthru: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 3/7] hw/usb/u2f-passthru: " Zhao Liu
@ 2024-07-15 9:44 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 9:44 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel
On 15/7/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> hw/usb/u2f-passthru.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 6/7] backends/iommufd: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 6/7] backends/iommufd: " Zhao Liu
@ 2024-07-15 9:45 ` Philippe Mathieu-Daudé
2024-07-16 8:10 ` Yi Liu
1 sibling, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 9:45 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel, Yi Liu, Eric Auger, Zhenzhong Duan
On 15/7/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Cc: Yi Liu <yi.l.liu@intel.com>
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> backends/iommufd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/7] backends/hostmem-epc: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 5/7] backends/hostmem-epc: " Zhao Liu
@ 2024-07-15 9:45 ` Philippe Mathieu-Daudé
2024-07-15 14:02 ` Igor Mammedov
1 sibling, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 9:45 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel, David Hildenbrand, Igor Mammedov
On 15/7/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> backends/hostmem-epc.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/7] hw/vfio/container: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 4/7] hw/vfio/container: " Zhao Liu
@ 2024-07-15 9:46 ` Philippe Mathieu-Daudé
2024-07-16 13:43 ` Cédric Le Goater
1 sibling, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 9:46 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel, Alex Williamson, Cédric Le Goater
On 15/7/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: "Cédric Le Goater" <clg@redhat.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> hw/vfio/container.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 7/7] backends/rng-random: " Zhao Liu
@ 2024-07-15 9:46 ` Philippe Mathieu-Daudé
2024-07-15 10:10 ` Zhao Liu
0 siblings, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 9:46 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel, Laurent Vivier, Amit Shah
On 15/7/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open(). And considering
> rng_random_opened() will lose its obvious error handling case after
> removing error_setg_file_open(), add comment to remind here.
>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Amit Shah <amit@kernel.org>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> backends/rng-random.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/backends/rng-random.c b/backends/rng-random.c
> index 80eb5be138ce..3cdb982533b5 100644
> --- a/backends/rng-random.c
> +++ b/backends/rng-random.c
> @@ -75,10 +75,11 @@ static void rng_random_opened(RngBackend *b, Error **errp)
> error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> "filename", "a valid filename");
> } else {
> - s->fd = qemu_open_old(s->filename, O_RDONLY | O_NONBLOCK);
> - if (s->fd == -1) {
> - error_setg_file_open(errp, errno, s->filename);
> - }
> + /*
> + * Once the open fails, the error message is integrated into
> + * the *errp object by qemu_open().
> + */
IMHO this comment is superfluous, I'd drop it, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> + s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK, errp);
> }
> }
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
2024-07-15 9:46 ` Philippe Mathieu-Daudé
@ 2024-07-15 10:10 ` Zhao Liu
2024-07-15 11:07 ` Michael Tokarev
0 siblings, 1 reply; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 10:10 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Laurent Vivier, Daniel P . Berrangé, Markus Armbruster,
Eric Blake, qemu-trivial, qemu-devel, Laurent Vivier, Amit Shah
On Mon, Jul 15, 2024 at 11:46:54AM +0200, Philippe Mathieu-Daudé wrote:
> Date: Mon, 15 Jul 2024 11:46:54 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: Re: [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
>
> On 15/7/24 10:21, Zhao Liu wrote:
> > For qemu_open_old(), osdep.h said:
> >
> > > Don't introduce new usage of this function, prefer the following
> > > qemu_open/qemu_create that take an "Error **errp".
> >
> > So replace qemu_open_old() with qemu_open(). And considering
> > rng_random_opened() will lose its obvious error handling case after
> > removing error_setg_file_open(), add comment to remind here.
> >
> > Cc: Laurent Vivier <lvivier@redhat.com>
> > Cc: Amit Shah <amit@kernel.org>
> > Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> > ---
> > backends/rng-random.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/backends/rng-random.c b/backends/rng-random.c
> > index 80eb5be138ce..3cdb982533b5 100644
> > --- a/backends/rng-random.c
> > +++ b/backends/rng-random.c
> > @@ -75,10 +75,11 @@ static void rng_random_opened(RngBackend *b, Error **errp)
> > error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> > "filename", "a valid filename");
> > } else {
> > - s->fd = qemu_open_old(s->filename, O_RDONLY | O_NONBLOCK);
> > - if (s->fd == -1) {
> > - error_setg_file_open(errp, errno, s->filename);
> > - }
> > + /*
> > + * Once the open fails, the error message is integrated into
> > + * the *errp object by qemu_open().
> > + */
>
> IMHO this comment is superfluous, I'd drop it, otherwise:
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
Thanks Philippe! I'll wait patch 1's comment, after that I can post a
new version with the change you mentioned.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
2024-07-15 10:10 ` Zhao Liu
@ 2024-07-15 11:07 ` Michael Tokarev
2024-07-15 12:44 ` Zhao Liu
0 siblings, 1 reply; 20+ messages in thread
From: Michael Tokarev @ 2024-07-15 11:07 UTC (permalink / raw)
To: Zhao Liu, Philippe Mathieu-Daudé
Cc: Laurent Vivier, Daniel P. Berrangé, Markus Armbruster,
Eric Blake, qemu-trivial, qemu-devel, Amit Shah
15.07.2024 13:10, Zhao Liu wrote:
...
> Thanks Philippe! I'll wait patch 1's comment, after that I can post a
> new version with the change you mentioned.
I don't think either of this is necessary. Patch 1 LGTM, and I'll
drop the comment while applying.
/mjt
--
GPG Key transition (from rsa2048 to rsa4096) since 2024-04-24.
New key: rsa4096/61AD3D98ECDF2C8E 9D8B E14E 3F2A 9DD7 9199 28F1 61AD 3D98 ECDF 2C8E
Old key: rsa2048/457CE0A0804465C5 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5
Transition statement: http://www.corpit.ru/mjt/gpg-transition-2024.txt
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
2024-07-15 11:07 ` Michael Tokarev
@ 2024-07-15 12:44 ` Zhao Liu
0 siblings, 0 replies; 20+ messages in thread
From: Zhao Liu @ 2024-07-15 12:44 UTC (permalink / raw)
To: Michael Tokarev
Cc: Philippe Mathieu-Daudé, Laurent Vivier,
Daniel P. Berrangé, Markus Armbruster, Eric Blake,
qemu-trivial, qemu-devel, Amit Shah
On Mon, Jul 15, 2024 at 02:07:00PM +0300, Michael Tokarev wrote:
> Date: Mon, 15 Jul 2024 14:07:00 +0300
> From: Michael Tokarev <mjt@tls.msk.ru>
> Subject: Re: [PATCH 7/7] backends/rng-random: Get rid of qemu_open_old()
>
> 15.07.2024 13:10, Zhao Liu wrote:
> ...
> > Thanks Philippe! I'll wait patch 1's comment, after that I can post a
> > new version with the change you mentioned.
>
> I don't think either of this is necessary. Patch 1 LGTM, and I'll
> drop the comment while applying.
>
Many thanks!
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/7] backends/hostmem-epc: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 5/7] backends/hostmem-epc: " Zhao Liu
2024-07-15 9:45 ` Philippe Mathieu-Daudé
@ 2024-07-15 14:02 ` Igor Mammedov
1 sibling, 0 replies; 20+ messages in thread
From: Igor Mammedov @ 2024-07-15 14:02 UTC (permalink / raw)
To: Zhao Liu
Cc: Michael Tokarev, Laurent Vivier, Daniel P . Berrangé,
Markus Armbruster, Eric Blake, Philippe Mathieu-Daudé,
qemu-trivial, qemu-devel, David Hildenbrand
On Mon, 15 Jul 2024 16:21:53 +0800
Zhao Liu <zhao1.liu@intel.com> wrote:
> For qemu_open_old(), osdep.h said:
>
> > Don't introduce new usage of this function, prefer the following
> > qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> backends/hostmem-epc.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c
> index f58fcf00a10b..6c024d6217d2 100644
> --- a/backends/hostmem-epc.c
> +++ b/backends/hostmem-epc.c
> @@ -29,10 +29,8 @@ sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> return false;
> }
>
> - fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
> + fd = qemu_open("/dev/sgx_vepc", O_RDWR, errp);
> if (fd < 0) {
> - error_setg_errno(errp, errno,
> - "failed to open /dev/sgx_vepc to alloc SGX EPC");
> return false;
> }
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 6/7] backends/iommufd: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 6/7] backends/iommufd: " Zhao Liu
2024-07-15 9:45 ` Philippe Mathieu-Daudé
@ 2024-07-16 8:10 ` Yi Liu
1 sibling, 0 replies; 20+ messages in thread
From: Yi Liu @ 2024-07-16 8:10 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel, Eric Auger,
Zhenzhong Duan
On 2024/7/15 16:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Cc: Yi Liu <yi.l.liu@intel.com>
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> backends/iommufd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
> diff --git a/backends/iommufd.c b/backends/iommufd.c
> index 84fefbc9ee7a..cabd1b50025d 100644
> --- a/backends/iommufd.c
> +++ b/backends/iommufd.c
> @@ -77,9 +77,8 @@ bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp)
> int fd;
>
> if (be->owned && !be->users) {
> - fd = qemu_open_old("/dev/iommu", O_RDWR);
> + fd = qemu_open("/dev/iommu", O_RDWR, errp);
> if (fd < 0) {
> - error_setg_errno(errp, errno, "/dev/iommu opening failed");
> return false;
> }
> be->fd = fd;
--
Regards,
Yi Liu
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/7] hw/vfio/container: Get rid of qemu_open_old()
2024-07-15 8:21 ` [PATCH 4/7] hw/vfio/container: " Zhao Liu
2024-07-15 9:46 ` Philippe Mathieu-Daudé
@ 2024-07-16 13:43 ` Cédric Le Goater
1 sibling, 0 replies; 20+ messages in thread
From: Cédric Le Goater @ 2024-07-16 13:43 UTC (permalink / raw)
To: Zhao Liu, Michael Tokarev, Laurent Vivier
Cc: Daniel P . Berrangé, Markus Armbruster, Eric Blake,
Philippe Mathieu-Daudé, qemu-trivial, qemu-devel,
Alex Williamson
On 7/15/24 10:21, Zhao Liu wrote:
> For qemu_open_old(), osdep.h said:
>
>> Don't introduce new usage of this function, prefer the following
>> qemu_open/qemu_create that take an "Error **errp".
>
> So replace qemu_open_old() with qemu_open().
>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: "Cédric Le Goater" <clg@redhat.com>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> hw/vfio/container.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index 425db1a14c07..38a9df34964a 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -600,9 +600,8 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> }
> }
>
> - fd = qemu_open_old("/dev/vfio/vfio", O_RDWR);
> + fd = qemu_open("/dev/vfio/vfio", O_RDWR, errp);
> if (fd < 0) {
> - error_setg_errno(errp, errno, "failed to open /dev/vfio/vfio");
> goto put_space_exit;
> }
>
> @@ -743,9 +742,8 @@ static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
> group = g_malloc0(sizeof(*group));
>
> snprintf(path, sizeof(path), "/dev/vfio/%d", groupid);
> - group->fd = qemu_open_old(path, O_RDWR);
> + group->fd = qemu_open(path, O_RDWR, errp);
> if (group->fd < 0) {
> - error_setg_errno(errp, errno, "failed to open %s", path);
> goto free_group_exit;
> }
>
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-07-16 13:43 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-15 8:21 [PATCH 0/7] trivial: Replace some qemu_open_old() with qemu_open() Zhao Liu
2024-07-15 8:21 ` [PATCH 1/7] hw/i386/sgx: Get rid of qemu_open_old() Zhao Liu
2024-07-15 8:21 ` [PATCH 2/7] hw/usb/host-libusb: " Zhao Liu
2024-07-15 9:44 ` Philippe Mathieu-Daudé
2024-07-15 8:21 ` [PATCH 3/7] hw/usb/u2f-passthru: " Zhao Liu
2024-07-15 9:44 ` Philippe Mathieu-Daudé
2024-07-15 8:21 ` [PATCH 4/7] hw/vfio/container: " Zhao Liu
2024-07-15 9:46 ` Philippe Mathieu-Daudé
2024-07-16 13:43 ` Cédric Le Goater
2024-07-15 8:21 ` [PATCH 5/7] backends/hostmem-epc: " Zhao Liu
2024-07-15 9:45 ` Philippe Mathieu-Daudé
2024-07-15 14:02 ` Igor Mammedov
2024-07-15 8:21 ` [PATCH 6/7] backends/iommufd: " Zhao Liu
2024-07-15 9:45 ` Philippe Mathieu-Daudé
2024-07-16 8:10 ` Yi Liu
2024-07-15 8:21 ` [PATCH 7/7] backends/rng-random: " Zhao Liu
2024-07-15 9:46 ` Philippe Mathieu-Daudé
2024-07-15 10:10 ` Zhao Liu
2024-07-15 11:07 ` Michael Tokarev
2024-07-15 12:44 ` Zhao Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).