All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Alex Fishman <alex.fishman@ravellosystems.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	yvugenfi@redhat.com, Izik Eidus <izik.eidus@ravellosystems.com>,
	qemu-devel@nongnu.org, Yan Vugenfirer <yan@daynix.com>,
	Dmitry Fleytman <dmitry@daynix.com>
Subject: Re: [Qemu-devel] [PATCH 2/5] Vendor name and product name parameters for SCSI devices Options "vendor_name" and "product_name" added for SCSI disks.
Date: Thu, 15 Mar 2012 10:55:01 +0100	[thread overview]
Message-ID: <4F61BC75.3030506@redhat.com> (raw)
In-Reply-To: <1331802150-12183-3-git-send-email-dmitry.fleytman@ravellosystems.com>

Il 15/03/2012 10:02, Dmitry Fleytman ha scritto:
> Sample command line is:
> 
>     -drive file=image.raw,if=none,cache=off,id=scsi1 \
>     -device lsi,id=scsi -device scsi-disk,drive=scsi1,bus=scsi.0,product_name="VENDOR SCSI DISK",vendor_name="[VENDOR]" \
> 
> Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
> Signed-off-by: Yan Vugenfirer <yan@daynix.com>
> ---
>  blockdev.h     |    6 +++++-
>  hw/scsi-disk.c |   51 ++++++++++++++++++++++++++++++++++++---------------
>  2 files changed, 41 insertions(+), 16 deletions(-)
> 
> diff --git a/blockdev.h b/blockdev.h
> index 260e16b..1813c53 100644
> --- a/blockdev.h
> +++ b/blockdev.h
> @@ -17,7 +17,9 @@
>  void blockdev_mark_auto_del(BlockDriverState *bs);
>  void blockdev_auto_del(BlockDriverState *bs);
>  
> -#define BLOCK_SERIAL_STRLEN 20
> +#define BLOCK_SERIAL_STRLEN  20
> +#define BLOCK_VENDOR_STRLEN  8
> +#define BLOCK_PRODUCT_STRLEN 16
>  
>  typedef enum {
>      IF_DEFAULT = -1,            /* for use with drive_add() only */
> @@ -37,6 +39,8 @@ struct DriveInfo {
>      int media_cd;
>      QemuOpts *opts;
>      char serial[BLOCK_SERIAL_STRLEN + 1];
> +    char vname[BLOCK_VENDOR_STRLEN + 1];
> +    char pname[BLOCK_PRODUCT_STRLEN + 1];
>      QTAILQ_ENTRY(DriveInfo) next;
>      int refcount;
>  };

Unused.

> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index add399e..0a12ea2 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;
>  };
> @@ -566,12 +568,23 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
>  
>      outbuf[0] = s->qdev.type & 0x1f;
>      outbuf[1] = s->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 {
> -        memcpy(&outbuf[16], "QEMU HARDDISK   ", 16);
> +        if (s->qdev.type == TYPE_ROM) {
> +            memcpy(&outbuf[16], "QEMU CD-ROM     ", 16);
> +        } else {
> +            memcpy(&outbuf[16], "QEMU HARDDISK   ", 16);
> +        }
>      }
> -    memcpy(&outbuf[8], "QEMU    ", 8);
> +
> +    if (NULL != s->vname) {
> +        strpadcpy((char *) &outbuf[8], 8, s->vname, ' ');
> +    } else {
> +        memcpy(&outbuf[8], "QEMU    ", 8);
> +    }
> +
>      memset(&outbuf[32], 0, 4);
>      memcpy(&outbuf[32], s->version, MIN(4, strlen(s->version)));
>      /*
> @@ -1585,14 +1598,19 @@ static int scsi_initfn(SCSIDevice *dev)
>          return -1;
>      }
>  
> -    if (!s->serial) {
> -        /* try to fall back to value set with legacy -drive serial=... */
> -        dinfo = drive_get_by_blockdev(s->qdev.conf.bs);
> -        if (*dinfo->serial) {
> -            s->serial = g_strdup(dinfo->serial);
> -        }
> -    }
> +    dinfo = drive_get_by_blockdev(s->qdev.conf.bs);
>  
> +    /* when no value given try to fall back to */
> +    /* value set with legacy -drive serial=... */
> +    if ((!s->serial) && (*dinfo->serial)) {
> +        s->serial = g_strdup(dinfo->serial);
> +    }

No need to change the way the serial is handled, because you don't need
dinfo for vname/pname.

> +    if ((!s->vname) && (*dinfo->vname)) {
> +        s->vname = g_strdup(dinfo->vname);
> +    }
> +    if ((!s->pname) && (*dinfo->pname)) {
> +        s->pname = g_strdup(dinfo->pname);
> +    }

(Also, no parentheses around simple conditions).

>      if (!s->version) {
>          s->version = g_strdup(QEMU_VERSION);
>      }
> @@ -1788,10 +1806,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

  reply	other threads:[~2012-03-15  9:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15  9:02 [Qemu-devel] [PATCH 0/5] VMWare PVSCSI paravirtual device implementation Dmitry Fleytman
2012-03-15  9:02 ` [Qemu-devel] [PATCH 1/5] Utility function strpadcpy() added Dmitry Fleytman
2012-03-15  9:53   ` Paolo Bonzini
2012-03-18  9:22     ` Dmitry Fleytman
2012-03-15  9:02 ` [Qemu-devel] [PATCH 2/5] Vendor name and product name parameters for SCSI devices Options "vendor_name" and "product_name" added for SCSI disks Dmitry Fleytman
2012-03-15  9:55   ` Paolo Bonzini [this message]
2012-03-18  9:24     ` Dmitry Fleytman
2012-03-15  9:02 ` [Qemu-devel] [PATCH 3/5] Header with various utility functions shared by VMWARE SCSI and network devices Dmitry Fleytman
2012-03-15  9:56   ` Paolo Bonzini
2012-03-18  9:23     ` Dmitry Fleytman
2012-03-15  9:02 ` [Qemu-devel] [PATCH 4/5] PVCSI paravirtualized device implementation Dmitry Fleytman
2012-03-15  9:02 ` [Qemu-devel] [PATCH 5/5] PVSCSI paravirtualized device integration Bus type "pvscsi" added Dmitry Fleytman
2012-03-15  9:46   ` Paolo Bonzini
2012-03-18  9:15     ` Dmitry Fleytman
2012-03-15 11:47 ` [Qemu-devel] [PATCH 0/5] VMWare PVSCSI paravirtual device implementation Stefan Hajnoczi
2012-03-15 11:54   ` Paolo Bonzini
2012-03-15 11:54   ` Daniel P. Berrange
2012-03-15 12:29   ` Avi Kivity
2012-03-18  8:31 ` Gerhard Wiesinger
2012-03-18  8:32 ` Gerhard Wiesinger
2012-03-18 12:33   ` Evgeny Budilovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F61BC75.3030506@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.fishman@ravellosystems.com \
    --cc=aliguori@us.ibm.com \
    --cc=dmitry.fleytman@ravellosystems.com \
    --cc=dmitry@daynix.com \
    --cc=izik.eidus@ravellosystems.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yan@daynix.com \
    --cc=yvugenfi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.