diff mbox

[3/3] megasas: Use qemu_hw_version() instead of QEMU_VERSION

Message ID 1442952987-20187-4-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Sept. 22, 2015, 8:16 p.m. UTC
Guest visible data shouldn't change with a simple QEMU upgrade, so use
qemu_hw_version() to ensure it won't change (as long as the machine
class being used has hw_version set).

Cc: Hannes Reinecke <hare@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/scsi/megasas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hannes Reinecke Sept. 22, 2015, 8:21 p.m. UTC | #1
On 09/22/2015 10:16 PM, Eduardo Habkost wrote:
> Guest visible data shouldn't change with a simple QEMU upgrade, so use
> qemu_hw_version() to ensure it won't change (as long as the machine
> class being used has hw_version set).
> 
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: qemu-block@nongnu.org
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/scsi/megasas.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index a04369c..e0529b1 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
>  
>      memcpy(info.product_name, base_class->product_name, 24);
>      snprintf(info.serial_number, 32, "%s", s->hba_serial);
> -    snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION);
> +    snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
>      memcpy(info.image_component[0].name, "APP", 3);
>      snprintf(info.image_component[0].version, 10, "%s-QEMU",
>               base_class->product_version);
> 
Ah. right. Should be okay, then.

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
Laszlo Ersek Sept. 22, 2015, 8:33 p.m. UTC | #2
On 09/22/15 22:16, Eduardo Habkost wrote:
> Guest visible data shouldn't change with a simple QEMU upgrade, so use
> qemu_hw_version() to ensure it won't change (as long as the machine
> class being used has hw_version set).
> 
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: qemu-block@nongnu.org
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/scsi/megasas.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index a04369c..e0529b1 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
>  
>      memcpy(info.product_name, base_class->product_name, 24);
>      snprintf(info.serial_number, 32, "%s", s->hba_serial);
> -    snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION);
> +    snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
>      memcpy(info.image_component[0].name, "APP", 3);
>      snprintf(info.image_component[0].version, 10, "%s-QEMU",
>               base_class->product_version);
> 

I assume you audited all uses of QEMU_VERSION, and this was the only one
exposed to the guest directly.

However, in "hw/usb/redirect.c", QEMU_VERSION is embedded in VERSION,
and the latter is then passed to usbredirparser_init() in
usbredir_create_parser().

I tried to look up the documentation for usbredirparser_init() in
"/usr/include/usbredirparser.h", but I still have no clue what that
"version" parameter controls.

Hm... from the source code of usbredir, and
<http://www.spice-space.org/page/UsbRedir> stating "usbredir is the name
of a network protocol for sending usb device traffic over a network
connection", it looks like the version number is embedded in the hello
message of that network protocol; so it shouldn't be exposed to the
guest indeed.

Acked-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo
Eduardo Habkost Sept. 22, 2015, 8:36 p.m. UTC | #3
On Tue, Sep 22, 2015 at 10:33:32PM +0200, Laszlo Ersek wrote:
> On 09/22/15 22:16, Eduardo Habkost wrote:
> > Guest visible data shouldn't change with a simple QEMU upgrade, so use
> > qemu_hw_version() to ensure it won't change (as long as the machine
> > class being used has hw_version set).
> > 
> > Cc: Hannes Reinecke <hare@suse.de>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: qemu-block@nongnu.org
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  hw/scsi/megasas.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> > index a04369c..e0529b1 100644
> > --- a/hw/scsi/megasas.c
> > +++ b/hw/scsi/megasas.c
> > @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
> >  
> >      memcpy(info.product_name, base_class->product_name, 24);
> >      snprintf(info.serial_number, 32, "%s", s->hba_serial);
> > -    snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION);
> > +    snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
> >      memcpy(info.image_component[0].name, "APP", 3);
> >      snprintf(info.image_component[0].version, 10, "%s-QEMU",
> >               base_class->product_version);
> > 
> 
> I assume you audited all uses of QEMU_VERSION, and this was the only one
> exposed to the guest directly.
> 
> However, in "hw/usb/redirect.c", QEMU_VERSION is embedded in VERSION,
> and the latter is then passed to usbredirparser_init() in
> usbredir_create_parser().
> 
> I tried to look up the documentation for usbredirparser_init() in
> "/usr/include/usbredirparser.h", but I still have no clue what that
> "version" parameter controls.
> 
> Hm... from the source code of usbredir, and
> <http://www.spice-space.org/page/UsbRedir> stating "usbredir is the name
> of a network protocol for sending usb device traffic over a network
> connection", it looks like the version number is embedded in the hello
> message of that network protocol; so it shouldn't be exposed to the
> guest indeed.

Investigating how VERSION was used in usbredirparser was next on my
todo-list. Thanks for doing that. :)
diff mbox

Patch

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index a04369c..e0529b1 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -757,7 +757,7 @@  static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
 
     memcpy(info.product_name, base_class->product_name, 24);
     snprintf(info.serial_number, 32, "%s", s->hba_serial);
-    snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION);
+    snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
     memcpy(info.image_component[0].name, "APP", 3);
     snprintf(info.image_component[0].version, 10, "%s-QEMU",
              base_class->product_version);