Patchwork [10/10] Compile virtio-blk only once

login
register
mail settings
Submitter Blue Swirl
Date March 26, 2010, 7:04 p.m.
Message ID <f43fc5581003261204i596f1f95qfb70129e58800cdf@mail.gmail.com>
Download mbox | patch
Permalink /patch/48720/
State New
Headers show

Comments

Blue Swirl - March 26, 2010, 7:04 p.m.
Replace access macros with direct accesses.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 Makefile.objs   |    3 ++-
 Makefile.target |    2 +-
 hw/virtio-blk.c |    6 +++---
 3 files changed, 6 insertions(+), 5 deletions(-)

     blkcfg.blk_size = s->conf->logical_block_size;
Anthony Liguori - March 26, 2010, 8:33 p.m.
On 03/26/2010 02:04 PM, Blue Swirl wrote:
> Replace access macros with direct accesses.
>
> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
> ---
>   Makefile.objs   |    3 ++-
>   Makefile.target |    2 +-
>   hw/virtio-blk.c |    6 +++---
>   3 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile.objs b/Makefile.objs
> index cad6490..5612ec2 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -128,7 +128,8 @@ user-obj-y += cutils.o cache-utils.o
>
>   hw-obj-y =
>   hw-obj-y += loader.o
> -hw-obj-y += virtio.o virtio-console.o virtio-pci.o virtio-net.o
> virtio-serial-bus.o
> +hw-obj-y += virtio.o virtio-console.o virtio-pci.o
> +hw-obj-y += virtio-blk.o virtio-net.o virtio-serial-bus.o
>   hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
>   hw-obj-y += watchdog.o
>   hw-obj-$(CONFIG_ISA_MMIO) += isa_mmio.o
> diff --git a/Makefile.target b/Makefile.target
> index e43e138..169c11e 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -165,7 +165,7 @@ obj-y = vl.o monitor.o machine.o gdbstub.o
>   obj-y += qemu-timer.o
>   # virtio has to be here due to weird dependency between PCI and virtio-net.
>   # need to fix this properly
> -obj-y += virtio-blk.o virtio-balloon.o
> +obj-y += virtio-balloon.o
>   obj-y += rwhandler.o
>   obj-$(CONFIG_KVM) += kvm.o kvm-all.o
>   LIBS+=-lz
> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index 9915840..d9dd9a7 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -411,9 +411,9 @@ static void virtio_blk_update_config(VirtIODevice
> *vdev, uint8_t *config)
>       bdrv_get_geometry(s->bs,&capacity);
>       bdrv_get_geometry_hint(s->bs,&cylinders,&heads,&secs);
>       memset(&blkcfg, 0, sizeof(blkcfg));
> -    stq_raw(&blkcfg.capacity, capacity);
> -    stl_raw(&blkcfg.seg_max, 128 - 2);
> -    stw_raw(&blkcfg.cylinders, cylinders);
> +    blkcfg.capacity = capacity;
> +    blkcfg.seg_max = 128 - 2;
> +    blkcfg.cylinders = cylinders;
>    

This looks wrong to me.

These values need to be in guest endianness.

Regards,

Anthony Liguori

>       blkcfg.heads = heads;
>       blkcfg.sectors = secs&  ~s->sector_mask;
>       blkcfg.blk_size = s->conf->logical_block_size;
>
Blue Swirl - March 26, 2010, 9:35 p.m.
On 3/26/10, Anthony Liguori <anthony@codemonkey.ws> wrote:
> On 03/26/2010 02:04 PM, Blue Swirl wrote:
>
> > Replace access macros with direct accesses.
> >
> > Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
> > ---
> >  Makefile.objs   |    3 ++-
> >  Makefile.target |    2 +-
> >  hw/virtio-blk.c |    6 +++---
> >  3 files changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/Makefile.objs b/Makefile.objs
> > index cad6490..5612ec2 100644
> > --- a/Makefile.objs
> > +++ b/Makefile.objs
> > @@ -128,7 +128,8 @@ user-obj-y += cutils.o cache-utils.o
> >
> >  hw-obj-y =
> >  hw-obj-y += loader.o
> > -hw-obj-y += virtio.o virtio-console.o virtio-pci.o virtio-net.o
> > virtio-serial-bus.o
> > +hw-obj-y += virtio.o virtio-console.o virtio-pci.o
> > +hw-obj-y += virtio-blk.o virtio-net.o virtio-serial-bus.o
> >  hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
> >  hw-obj-y += watchdog.o
> >  hw-obj-$(CONFIG_ISA_MMIO) += isa_mmio.o
> > diff --git a/Makefile.target b/Makefile.target
> > index e43e138..169c11e 100644
> > --- a/Makefile.target
> > +++ b/Makefile.target
> > @@ -165,7 +165,7 @@ obj-y = vl.o monitor.o machine.o gdbstub.o
> >  obj-y += qemu-timer.o
> >  # virtio has to be here due to weird dependency between PCI and
> virtio-net.
> >  # need to fix this properly
> > -obj-y += virtio-blk.o virtio-balloon.o
> > +obj-y += virtio-balloon.o
> >  obj-y += rwhandler.o
> >  obj-$(CONFIG_KVM) += kvm.o kvm-all.o
> >  LIBS+=-lz
> > diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> > index 9915840..d9dd9a7 100644
> > --- a/hw/virtio-blk.c
> > +++ b/hw/virtio-blk.c
> > @@ -411,9 +411,9 @@ static void
> virtio_blk_update_config(VirtIODevice
> > *vdev, uint8_t *config)
> >      bdrv_get_geometry(s->bs,&capacity);
> >
> bdrv_get_geometry_hint(s->bs,&cylinders,&heads,&secs);
> >      memset(&blkcfg, 0, sizeof(blkcfg));
> > -    stq_raw(&blkcfg.capacity, capacity);
> > -    stl_raw(&blkcfg.seg_max, 128 - 2);
> > -    stw_raw(&blkcfg.cylinders, cylinders);
> > +    blkcfg.capacity = capacity;
> > +    blkcfg.seg_max = 128 - 2;
> > +    blkcfg.cylinders = cylinders;
> >
> >
>
>  This looks wrong to me.
>
>  These values need to be in guest endianness.

Then we probably need a flag to indicate the endianness, passed from
virtio-pci. It gets a bit more complicated.

Patch

diff --git a/Makefile.objs b/Makefile.objs
index cad6490..5612ec2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -128,7 +128,8 @@  user-obj-y += cutils.o cache-utils.o

 hw-obj-y =
 hw-obj-y += loader.o
-hw-obj-y += virtio.o virtio-console.o virtio-pci.o virtio-net.o
virtio-serial-bus.o
+hw-obj-y += virtio.o virtio-console.o virtio-pci.o
+hw-obj-y += virtio-blk.o virtio-net.o virtio-serial-bus.o
 hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
 hw-obj-y += watchdog.o
 hw-obj-$(CONFIG_ISA_MMIO) += isa_mmio.o
diff --git a/Makefile.target b/Makefile.target
index e43e138..169c11e 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -165,7 +165,7 @@  obj-y = vl.o monitor.o machine.o gdbstub.o
 obj-y += qemu-timer.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
-obj-y += virtio-blk.o virtio-balloon.o
+obj-y += virtio-balloon.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 LIBS+=-lz
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 9915840..d9dd9a7 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -411,9 +411,9 @@  static void virtio_blk_update_config(VirtIODevice
*vdev, uint8_t *config)
     bdrv_get_geometry(s->bs, &capacity);
     bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
     memset(&blkcfg, 0, sizeof(blkcfg));
-    stq_raw(&blkcfg.capacity, capacity);
-    stl_raw(&blkcfg.seg_max, 128 - 2);
-    stw_raw(&blkcfg.cylinders, cylinders);
+    blkcfg.capacity = capacity;
+    blkcfg.seg_max = 128 - 2;
+    blkcfg.cylinders = cylinders;
     blkcfg.heads = heads;
     blkcfg.sectors = secs & ~s->sector_mask;