]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/usb: Convert to qemu_create() for a better error message
authorMarkus Armbruster <armbru@redhat.com>
Fri, 21 Nov 2025 12:14:25 +0000 (13:14 +0100)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 25 Nov 2025 21:41:47 +0000 (22:41 +0100)
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>
hw/usb/bus.c

index 8dd2ce415eb01f653bcee8c63cae3d08bb34fc67..714e33989f458fd4620972d86518a57feaf05cbd 100644 (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;
         }