hw/usb: Convert to qemu_create() for a better error message

The error message changes from

    open FILENAME failed

to

    Could not create 'FILENAME': REASON

where REASON is the value of strerror(errno).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251121121438.1249498-3-armbru@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Markus Armbruster 2025-11-21 13:14:25 +01:00 committed by Philippe Mathieu-Daudé
parent a5da8dd90b
commit 622a0c9dee

View file

@ -259,10 +259,9 @@ static void usb_qdev_realize(DeviceState *qdev, Error **errp)
}
if (dev->pcap_filename) {
int fd = qemu_open_old(dev->pcap_filename,
O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
int fd = qemu_create(dev->pcap_filename,
O_WRONLY | O_TRUNC | O_BINARY, 0666, errp);
if (fd < 0) {
error_setg(errp, "open %s failed", dev->pcap_filename);
usb_qdev_unrealize(qdev);
return;
}