Patchwork [2/4] Vendor name and product name parameters for SCSI devices

login
register
mail settings
Submitter Deep Debroy
Date July 7, 2012, 5:03 a.m.
Message ID <CABg=H3OFCJFB+NsU=2jHvCmbXcHjD4_0Q-BA6-z2GM5vK9T5kQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/169557/
State New
Headers show

Comments

Deep Debroy - July 7, 2012, 5:03 a.m.
Options vendor_name and product_nameadded for SCSI
 disks.


Signed-off-by: Deep Debroy <ddebroy@gmail.com>
---
 hw/scsi-disk.c |   31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

     /*
@@ -1914,10 +1926,13 @@ static SCSIRequest
*scsi_block_new_request(SCSIDevice *d, uint32_t tag,
 }
 #endif

-#define DEFINE_SCSI_DISK_PROPERTIES()                           \
-    DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),          \
-    DEFINE_PROP_STRING("ver",  SCSIDiskState, version),         \
-    DEFINE_PROP_STRING("serial",  SCSIDiskState, serial)
+#define DEFINE_SCSI_DISK_PROPERTIES()                                 \
+    DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),                \
+    DEFINE_PROP_STRING("ver",  SCSIDiskState, version),               \
+    DEFINE_PROP_STRING("serial",  SCSIDiskState, serial),             \
+    DEFINE_PROP_STRING("vendor_name",  SCSIDiskState, vname),         \
+    DEFINE_PROP_STRING("product_name",  SCSIDiskState, pname)
+

 static Property scsi_hd_properties[] = {
     DEFINE_SCSI_DISK_PROPERTIES(),
Paolo Bonzini - July 9, 2012, 6:55 a.m.
Il 07/07/2012 07:03, Deep Debroy ha scritto:
>  Options vendor_name and product_nameadded for SCSI
>  disks.

I renamed the property names to vendor/product (and similarly changed
the field names), and applied to scsi-next with correct attribution to
Dmitry Fleitman based on
http://lists.gnu.org/archive/html/qemu-devel/2012-03/msg03439.html.

Paolo

> 
> 
> Signed-off-by: Deep Debroy <ddebroy@gmail.com>
> ---
>  hw/scsi-disk.c |   31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index ae25194..a774c3c 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -70,6 +70,8 @@ struct SCSIDiskState
>      QEMUBH *bh;
>      char *version;
>      char *serial;
> +    char *vname;
> +    char *pname;
>      bool tray_open;
>      bool tray_locked;
>  };
> @@ -660,12 +662,22 @@ static int scsi_disk_emulate_inquiry(SCSIRequest
> *req, uint8_t *outbuf)
> 
>      outbuf[0] = s->qdev.type & 0x1f;
>      outbuf[1] = (s->features & (1 << SCSI_DISK_F_REMOVABLE)) ? 0x80 : 0;
> -    if (s->qdev.type == TYPE_ROM) {
> -        memcpy(&outbuf[16], "QEMU CD-ROM     ", 16);
> +
> +    if (NULL != s->pname) {
> +        strpadcpy((char *) &outbuf[16], 16, s->pname, ' ');
> +    } else {
> +        if (s->qdev.type == TYPE_ROM) {
> +            memcpy(&outbuf[16], "QEMU CD-ROM     ", 16);
> +        } else {
> +            memcpy(&outbuf[16], "QEMU HARDDISK   ", 16);
> +        }
> +    }
> +    if (NULL != s->vname) {
> +        strpadcpy((char *) &outbuf[8], 8, s->vname, ' ');
>      } else {
> -        memcpy(&outbuf[16], "QEMU HARDDISK   ", 16);
> +        memcpy(&outbuf[8], "QEMU    ", 8);
>      }
> -    memcpy(&outbuf[8], "QEMU    ", 8);
> +
>      memset(&outbuf[32], 0, 4);
>      memcpy(&outbuf[32], s->version, MIN(4, strlen(s->version)));
>      /*
> @@ -1914,10 +1926,13 @@ static SCSIRequest
> *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
>  }
>  #endif
> 
> -#define DEFINE_SCSI_DISK_PROPERTIES()                           \
> -    DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),          \
> -    DEFINE_PROP_STRING("ver",  SCSIDiskState, version),         \
> -    DEFINE_PROP_STRING("serial",  SCSIDiskState, serial)
> +#define DEFINE_SCSI_DISK_PROPERTIES()                                 \
> +    DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf),                \
> +    DEFINE_PROP_STRING("ver",  SCSIDiskState, version),               \
> +    DEFINE_PROP_STRING("serial",  SCSIDiskState, serial),             \
> +    DEFINE_PROP_STRING("vendor_name",  SCSIDiskState, vname),         \
> +    DEFINE_PROP_STRING("product_name",  SCSIDiskState, pname)
> +
> 
>  static Property scsi_hd_properties[] = {
>      DEFINE_SCSI_DISK_PROPERTIES(),
>

Patch

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index ae25194..a774c3c 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -70,6 +70,8 @@  struct SCSIDiskState
     QEMUBH *bh;
     char *version;
     char *serial;
+    char *vname;
+    char *pname;
     bool tray_open;
     bool tray_locked;
 };
@@ -660,12 +662,22 @@  static int scsi_disk_emulate_inquiry(SCSIRequest
*req, uint8_t *outbuf)

     outbuf[0] = s->qdev.type & 0x1f;
     outbuf[1] = (s->features & (1 << SCSI_DISK_F_REMOVABLE)) ? 0x80 : 0;
-    if (s->qdev.type == TYPE_ROM) {
-        memcpy(&outbuf[16], "QEMU CD-ROM     ", 16);
+
+    if (NULL != s->pname) {
+        strpadcpy((char *) &outbuf[16], 16, s->pname, ' ');
+    } else {
+        if (s->qdev.type == TYPE_ROM) {
+            memcpy(&outbuf[16], "QEMU CD-ROM     ", 16);
+        } else {
+            memcpy(&outbuf[16], "QEMU HARDDISK   ", 16);
+        }
+    }
+    if (NULL != s->vname) {
+        strpadcpy((char *) &outbuf[8], 8, s->vname, ' ');
     } else {
-        memcpy(&outbuf[16], "QEMU HARDDISK   ", 16);
+        memcpy(&outbuf[8], "QEMU    ", 8);
     }
-    memcpy(&outbuf[8], "QEMU    ", 8);
+
     memset(&outbuf[32], 0, 4);
     memcpy(&outbuf[32], s->version, MIN(4, strlen(s->version)));