Skip to contentSkip to conversation

virtio-serial: don't set MULTIPORT for 1 port dev

PATCH In review Michael S. Tsirkin 3 participants 9 messages Feb 12, 2010 – Feb 15, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-serial: don't set MULTIPORT for 1 port dev

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

---
 hw/virtio-serial-bus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
hw/virtio-serial-bus.c +4 -2
index ab456ea..d0e0219 100644
@@ -335,8 +335,10 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
 
 static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
 {
-    features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
-
+    VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+    if (vser->bus->max_nr_ports > 1) {
+        features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
+    }
     return features;
 }
 
Signature · 1 line
1.6.6.144.g5c3af
#1 lore raw
Quoted 4 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

In addition to this, setting max_nr_ports to 1 is needed when -M 0.12 is selected.

However, is this the only way to do it? Gerd?

Quoted 25 lines
---
 hw/virtio-serial-bus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
hw/virtio-serial-bus.c +4 -2
index ab456ea..d0e0219 100644
@@ -335,8 +335,10 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
 
 static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
 {
-    features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
-
+    VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+    if (vser->bus->max_nr_ports > 1) {
+        features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
+    }
     return features;
 }
 
Signature · 1 line
1.6.6.144.g5c3af

Amit

#2 lore raw
Quoted 8 lines · Amit Shah
Quoted 4 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

In addition to this, setting max_nr_ports to 1 is needed when -M 0.12 is selected.

Indeed.

Quoted 1 line

However, is this the only way to do it? Gerd?

Is there a qdev property for max_nr_ports? Then simply adding a compat property will do the trick.

cheers,
Gerd

#3 lore raw
Quoted 10 lines · Gerd Hoffmann
Quoted 8 lines · Amit Shah
Quoted 4 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

In addition to this, setting max_nr_ports to 1 is needed when -M 0.12 is selected.

Quoted 6 lines

Indeed.

Quoted 1 line

However, is this the only way to do it? Gerd?

Is there a qdev property for max_nr_ports? Then simply adding a compat property will do the trick.

Something like this (I can split it into two patches before submission):

hw/pc.c +38 -1
index 5b29f3b..a975934 100644
@@ -1055,12 +1055,32 @@ void cmos_set_s3_resume(void)
 }
 
 static QEMUMachine pc_machine = {
+    .name = "pc-0.13",
+    .alias = "pc",
+    .desc = "Standard PC",
+    .init = pc_init_pci,
+    .is_default = 1,
+    .max_cpus = 255,
+};
+
+static QEMUMachine pc_machine_v0_12 = {
     .name = "pc-0.12",
     .alias = "pc",
     .desc = "Standard PC",
     .init = pc_init_pci,
     .max_cpus = 255,
-    .is_default = 1,
+    .compat_props = (GlobalProperty[]) {
+        {
+            .driver   = "virtio-serial-pci",
+            .property = "max_nr_ports",
+            .value    = stringify(1),
+        },{
+            .driver   = "virtio-serial-pci",
+            .property = "vectors",
+            .value    = stringify(0),
+        },
+        { /* end of list */ }
+    }
 };
 
 static QEMUMachine pc_machine_v0_11 = {
@@ -1074,6 +1094,14 @@ static QEMUMachine pc_machine_v0_11 = {
             .property = "vectors",
             .value    = stringify(0),
         },{
+            .driver   = "virtio-serial-pci",
+            .property = "max_nr_ports",
+            .value    = stringify(1),
+        },{
+            .driver   = "virtio-serial-pci",
+            .property = "vectors",
+            .value    = stringify(0),
+        },{
             .driver   = "ide-drive",
             .property = "ver",
             .value    = "0.11",
@@ -1105,6 +1133,14 @@ static QEMUMachine pc_machine_v0_10 = {
             .property = "class",
             .value    = stringify(PCI_CLASS_DISPLAY_OTHER),
         },{
+            .driver   = "virtio-serial-pci",
+            .property = "max_nr_ports",
+            .value    = stringify(1),
+        },{
+            .driver   = "virtio-serial-pci",
+            .property = "vectors",
+            .value    = stringify(0),
+        },{
             .driver   = "virtio-net-pci",
             .property = "vectors",
             .value    = stringify(0),
@@ -1139,6 +1175,7 @@ static QEMUMachine isapc_machine = {
 static void pc_machine_init(void)
 {
     qemu_register_machine(&pc_machine);
+    qemu_register_machine(&pc_machine_v0_12);
     qemu_register_machine(&pc_machine_v0_11);
     qemu_register_machine(&pc_machine_v0_10);
     qemu_register_machine(&isapc_machine);

Amit

#4 lore raw
Quoted 11 lines · Amit Shah
Quoted 10 lines · Gerd Hoffmann
Quoted 8 lines · Amit Shah
Quoted 4 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

In addition to this, setting max_nr_ports to 1 is needed when -M 0.12 is selected.

Quoted 9 lines
Quoted 6 lines

Indeed.

Quoted 1 line

However, is this the only way to do it? Gerd?

Is there a qdev property for max_nr_ports? Then simply adding a compat property will do the trick.

Something like this (I can split it into two patches before submission):

Right. So, can you ack my patch pls?

Quoted 78 lines
hw/pc.c +38 -1
index 5b29f3b..a975934 100644
@@ -1055,12 +1055,32 @@ void cmos_set_s3_resume(void)
 }
 
 static QEMUMachine pc_machine = {
+    .name = "pc-0.13",
+    .alias = "pc",
+    .desc = "Standard PC",
+    .init = pc_init_pci,
+    .is_default = 1,
+    .max_cpus = 255,
+};
+
+static QEMUMachine pc_machine_v0_12 = {
     .name = "pc-0.12",
     .alias = "pc",
     .desc = "Standard PC",
     .init = pc_init_pci,
     .max_cpus = 255,
-    .is_default = 1,
+    .compat_props = (GlobalProperty[]) {
+        {
+            .driver   = "virtio-serial-pci",
+            .property = "max_nr_ports",
+            .value    = stringify(1),
+        },{
+            .driver   = "virtio-serial-pci",
+            .property = "vectors",
+            .value    = stringify(0),
+        },
+        { /* end of list */ }
+    }
 };
 
 static QEMUMachine pc_machine_v0_11 = {
@@ -1074,6 +1094,14 @@ static QEMUMachine pc_machine_v0_11 = {
             .property = "vectors",
             .value    = stringify(0),
         },{
+            .driver   = "virtio-serial-pci",
+            .property = "max_nr_ports",
+            .value    = stringify(1),
+        },{
+            .driver   = "virtio-serial-pci",
+            .property = "vectors",
+            .value    = stringify(0),
+        },{
             .driver   = "ide-drive",
             .property = "ver",
             .value    = "0.11",
@@ -1105,6 +1133,14 @@ static QEMUMachine pc_machine_v0_10 = {
             .property = "class",
             .value    = stringify(PCI_CLASS_DISPLAY_OTHER),
         },{
+            .driver   = "virtio-serial-pci",
+            .property = "max_nr_ports",
+            .value    = stringify(1),
+        },{
+            .driver   = "virtio-serial-pci",
+            .property = "vectors",
+            .value    = stringify(0),
+        },{
             .driver   = "virtio-net-pci",
             .property = "vectors",
             .value    = stringify(0),
@@ -1139,6 +1175,7 @@ static QEMUMachine isapc_machine = {
 static void pc_machine_init(void)
 {
     qemu_register_machine(&pc_machine);
+    qemu_register_machine(&pc_machine_v0_12);
     qemu_register_machine(&pc_machine_v0_11);
     qemu_register_machine(&pc_machine_v0_10);
     qemu_register_machine(&isapc_machine);

Amit

#5 lore raw
In reply to Amit Shah
Quoted 4 lines · Amit Shah
Quoted 2 lines

Is there a qdev property for max_nr_ports? Then simply adding a compat property will do the trick.

Something like this (I can split it into two patches before submission):

Yep, should be splitted.

Quoted 9 lines
hw/pc.c +1 -0
index 5b29f3b..a975934 100644
@@ -1055,12 +1055,32 @@ void cmos_set_s3_resume(void)
  }
 
  static QEMUMachine pc_machine = {
+    .name = "pc-0.13",

hw/pc.c void cmos_set_s3_resume(void) · line 1068

Quoted 10 lines
hw/pc.c +8 -0
+    .alias = "pc",
+    .desc = "Standard PC",
+    .init = pc_init_pci,
+    .is_default = 1,
+    .max_cpus = 255,
+};
+
+static QEMUMachine pc_machine_v0_12 = {
      .name = "pc-0.12",
      .alias = "pc",

.alias should be dropped too.

cheers,
Gerd

Acked-by on v1 1/1
#6 lore raw
In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

A couple more patches are needed to introduce a 0.12 machine type and default to 1 max_nr_ports for machine types < 0.13, which I'll be sending shortly.

I'll also make this patch 3/3 in that series, just for completenes..

Amit

#7 lore raw
Quoted 6 lines · Amit Shah
Quoted 5 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

Quoted 7 lines
Quoted 1 line

A couple more patches are needed to introduce a 0.12 machine type and default to 1 max_nr_ports for machine types < 0.13, which I'll be sending shortly.

Note that we also need to fill in virtio feature bits for the rest of devices, per machine type. Care to deal with it?

Quoted 4 lines

I'll also make this patch 3/3 in that series, just for completenes..

Amit

#8 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Amit Shah
Quoted 6 lines · Michael S. Tsirkin

Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, all serial devices declare MULTIPORT feature.
To allow 0.12 compatibility, we should clear this when max_nr_ports is 1.

Quoted 8 lines
Quoted 5 lines

A couple more patches are needed to introduce a 0.12 machine type and default to 1 max_nr_ports for machine types < 0.13, which I'll be sending shortly.

Note that we also need to fill in virtio feature bits for the rest of devices, per machine type. Care to deal with it?

Yes, that has to be done (and at least for s390 and ppc for virtio-serial). I've not yet seen how they work, but they should be similar to pc (if at all they have similar versioning support).

Amit