Skip to contentSkip to conversation

Compile virtio-blk only once

PATCH In review Blue Swirl 2 participants 3 messages Mar 26, 2010 Kbuild

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

PATCH 10/10 Compile virtio-blk only once

Replace access macros with direct accesses.

---
 Makefile.objs   |    3 ++-
 Makefile.target |    2 +-
 hw/virtio-blk.c |    6 +++---
 3 files changed, 6 insertions(+), 5 deletions(-)
Makefile.objs +0 -1
index cad6490..5612ec2 100644
@@ -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

Makefile.target +1 -1
index e43e138..169c11e 100644
@@ -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
hw/virtio-blk.c +0 -0
index 9915840..d9dd9a7 100644
@@ -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;
     blkcfg.blk_size = s->conf->logical_block_size;
Signature · 1 line
1.6.2.4
#1 lore raw
Quoted 43 lines · Blue Swirl

Replace access macros with direct accesses.

---
  Makefile.objs   |    3 ++-
  Makefile.target |    2 +-
  hw/virtio-blk.c |    6 +++---
  3 files changed, 6 insertions(+), 5 deletions(-)
Makefile.objs +0 -1
index cad6490..5612ec2 100644
@@ -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

Makefile.objs +2 -0
+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
Makefile.target +1 -1
index e43e138..169c11e 100644
@@ -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
hw/virtio-blk.c +0 -0
index 9915840..d9dd9a7 100644
@@ -411,9 +411,9 @@ static void virtio_blk_update_config(VirtIODevice
 *vdev, uint8_t *config)

hw/virtio-blk.c static void virtio_blk_update_config(VirtIODevice · line 418

Quoted 10 lines
hw/virtio-blk.c +3 -3
      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

Quoted 4 lines
hw/virtio-blk.c +0 -0
      blkcfg.heads = heads;
      blkcfg.sectors = secs&  ~s->sector_mask;
      blkcfg.blk_size = s->conf->logical_block_size;
author
#2 lore raw
Quoted 60 lines · Anthony Liguori
Quoted 29 lines · Blue Swirl

Replace access macros with direct accesses.

---
 Makefile.objs   |    3 ++-
 Makefile.target |    2 +-
 hw/virtio-blk.c |    6 +++---
 3 files changed, 6 insertions(+), 5 deletions(-)
Makefile.objs +0 -1
index cad6490..5612ec2 100644
@@ -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

Makefile.objs +2 -0
+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
Makefile.target +0 -0
index e43e138..169c11e 100644

Makefile.target obj-y = vl.o monitor.o machine.o gdbstub.o · line 166

Quoted 2 lines
Makefile.target +0 -0
@@ -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.

hw/virtio-blk.c static void

Quoted 11 lines
Makefile.target +1 -1
 # 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
hw/virtio-blk.c +0 -0
index 9915840..d9dd9a7 100644
@@ -411,9 +411,9 @@ static void

virtio_blk_update_config(VirtIODevice

hw/virtio-blk.c static void · line 413

Quoted 3 lines
hw/virtio-blk.c +0 -0
 *vdev, uint8_t *config)
     bdrv_get_geometry(s->bs,&capacity);
 

bdrv_get_geometry_hint(s->bs,&cylinders,&heads,&secs);

hw/virtio-blk.c static void · line 419

Quoted 9 lines
hw/virtio-blk.c +3 -3
     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;
 
 
Quoted 3 lines

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.