qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting


From: Leandro Dorileo
Subject: [Qemu-devel] [PATCH 2/2] QError: vl.c drive_init porting
Date: Thu, 22 Apr 2010 18:01:46 -0400

Port of vl.c drive_init to QError API.

Signed-off-by: Leandro Dorileo <address@hidden>
---
 vl.c |   39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/vl.c b/vl.c
index e58441b..5be8516 100644
--- a/vl.c
+++ b/vl.c
@@ -853,31 +853,29 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
            type = IF_NONE;
             max_devs = 0;
        } else {
-            fprintf(stderr, "qemu: unsupported bus type '%s'\n", buf);
+            qerror_report(QERR_UNSUPPORTED_BUS_TYPE, buf);
             return NULL;
        }
     }
 
     if (cyls || heads || secs) {
         if (cyls < 1 || (type == IF_IDE && cyls > 16383)) {
-            fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", buf);
+            qerror_report(QERR_INVALID_PHYSICAL_NUMBER, buf, "cyls");
            return NULL;
        }
         if (heads < 1 || (type == IF_IDE && heads > 16)) {
-            fprintf(stderr, "qemu: '%s' invalid physical heads number\n", buf);
+            qerror_report(QERR_INVALID_PHYSICAL_NUMBER, buf, "heads");
            return NULL;
        }
         if (secs < 1 || (type == IF_IDE && secs > 63)) {
-            fprintf(stderr, "qemu: '%s' invalid physical secs number\n", buf);
+            qerror_report(QERR_INVALID_PHYSICAL_NUMBER, buf, "secs");
            return NULL;
        }
     }
 
     if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
         if (!cyls) {
-            fprintf(stderr,
-                    "qemu: '%s' trans must be used with cyls,heads and secs\n",
-                    buf);
+            qerror_report(QERR_MISSING_PARAMETER, "cyls");
             return NULL;
         }
         if (!strcmp(buf, "none"))
@@ -887,7 +885,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
         else if (!strcmp(buf, "auto"))
             translation = BIOS_ATA_TRANSLATION_AUTO;
        else {
-            fprintf(stderr, "qemu: '%s' invalid translation type\n", buf);
+            qerror_report(QERR_INVALID_PARAMETER, "trans");
            return NULL;
        }
     }
@@ -897,13 +895,12 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
            media = MEDIA_DISK;
        } else if (!strcmp(buf, "cdrom")) {
             if (cyls || secs || heads) {
-                fprintf(stderr,
-                        "qemu: '%s' invalid physical CHS format\n", buf);
+                qerror_report(QERR_INVALID_PHYSICAL_FORMAT, buf, "CHS");
                return NULL;
             }
            media = MEDIA_CDROM;
        } else {
-           fprintf(stderr, "qemu: '%s' invalid media\n", buf);
+        qerror_report(QERR_INVALID_PARAMETER, "media");
            return NULL;
        }
     }
@@ -916,7 +913,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
         else if (!strcmp(buf, "writeback"))
             cache = 2;
         else {
-           fprintf(stderr, "qemu: invalid cache option\n");
+            qerror_report(QERR_INVALID_PARAMETER, "cache");
            return NULL;
         }
     }
@@ -928,7 +925,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
         else if (!strcmp(buf, "native"))
             aio = 1;
         else {
-           fprintf(stderr, "qemu: invalid aio option\n");
+            qerror_report(QERR_INVALID_PARAMETER, "aio");
            return NULL;
         }
     }
@@ -943,7 +940,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
         }
         drv = bdrv_find_whitelisted_format(buf);
         if (!drv) {
-            fprintf(stderr, "qemu: '%s' invalid format\n", buf);
+            qerror_report(QERR_INVALID_PARAMETER, "format");
             return NULL;
         }
     }
@@ -951,7 +948,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     on_write_error = BLOCK_ERR_STOP_ENOSPC;
     if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
         if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
-            fprintf(stderr, "werror is no supported by this format\n");
+            qerror_report(QERR_UNSUPPORTED_PARAMETER_BY, "werror", devname);
             return NULL;
         }
 
@@ -964,7 +961,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     on_read_error = BLOCK_ERR_REPORT;
     if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
         if (type != IF_IDE && type != IF_VIRTIO) {
-            fprintf(stderr, "rerror is no supported by this format\n");
+            qerror_report(QERR_UNSUPPORTED_PARAMETER_BY, "rerror", devname);
             return NULL;
         }
 
@@ -976,7 +973,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
 
     if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
         if (type != IF_VIRTIO) {
-            fprintf(stderr, "addr is not supported\n");
+            qerror_report(QERR_UNSUPPORTED_PARAMETER_BY, "addr", devname);
             return NULL;
         }
     }
@@ -1017,8 +1014,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     /* check unit id */
 
     if (max_devs && unit_id >= max_devs) {
-        fprintf(stderr, "qemu: unit %d too big (max is %d)\n",
-                unit_id, max_devs - 1);
+        qerror_report(QERR_INVALID_UNIT_SIZE, unit_id, max_devs -1);
         return NULL;
     }
 
@@ -1122,7 +1118,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
         ro = 1;
     } else if (ro == 1) {
         if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {
-            fprintf(stderr, "qemu: readonly flag not supported for drive with 
this interface\n");
+            qerror_report(QERR_UNSUPPORTED_FLAG, "Readonly", devname);
             return NULL;
         }
     }
@@ -1130,8 +1126,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
 
     if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
-        fprintf(stderr, "qemu: could not open disk image %s: %s\n",
-                        file, strerror(errno));
+        qerror_report(QERR_OPEN_FILE_FAILED, file);
         return NULL;
     }
 
-- 
1.6.6.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]