qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation
  2015-10-16  8:49 [Qemu-devel] [PULL " Paolo Bonzini
@ 2015-10-16  8:49 ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2015-10-16  8:49 UTC (permalink / raw)
  To: qemu-devel

Conversion to Error * brings better error messages; before:

    qemu-system-x86_64: -chardev id=serial,backend=parallel,path=vl.c: Failed to create chardev

After:

    qemu-system-x86_64: -chardev id=serial,backend=parallel,path=vl.c: not a parallel port: Inappropriate ioctl for device

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-char.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 8567580..ff7722f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1753,12 +1753,13 @@ static void pp_close(CharDriverState *chr)
     qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
 }
 
-static CharDriverState *qemu_chr_open_pp_fd(int fd)
+static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp)
 {
     CharDriverState *chr;
     ParallelCharDriver *drv;
 
     if (ioctl(fd, PPCLAIM) < 0) {
+        error_setg_errno(errp, errno, "not a parallel port");
         close(fd);
         return NULL;
     }
@@ -1818,7 +1819,7 @@ static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
     return 0;
 }
 
-static CharDriverState *qemu_chr_open_pp_fd(int fd)
+static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp)
 {
     CharDriverState *chr;
 
@@ -3481,6 +3482,7 @@ static void qemu_chr_parse_serial(QemuOpts *opts, ChardevBackend *backend,
 }
 #endif
 
+#ifdef HAVE_CHARDEV_PARPORT
 static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend,
                                     Error **errp)
 {
@@ -3493,6 +3495,7 @@ static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend,
     backend->parallel = g_new0(ChardevHostdev, 1);
     backend->parallel->device = g_strdup(device);
 }
+#endif
 
 static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend,
                                 Error **errp)
@@ -4044,7 +4047,9 @@ static CharDriverState *qmp_chardev_open_serial(const char *id,
     return qemu_chr_open_win_path(serial->device, errp);
 }
 
-static CharDriverState *qmp_chardev_open_parallel(ChardevHostdev *parallel,
+static CharDriverState *qmp_chardev_open_parallel(const char *id,
+                                                  ChardevBackend *backend,
+                                                  ChardevReturn *ret,
                                                   Error **errp)
 {
     error_setg(errp, "character device backend type 'parallel' not supported");
@@ -4110,16 +4115,19 @@ static CharDriverState *qmp_chardev_open_serial(const char *id,
 #endif
 
 #ifdef HAVE_CHARDEV_PARPORT
-static CharDriverState *qmp_chardev_open_parallel(ChardevHostdev *parallel,
+static CharDriverState *qmp_chardev_open_parallel(const char *id,
+                                                  ChardevBackend *backend,
+                                                  ChardevReturn *ret,
                                                   Error **errp)
 {
+    ChardevHostdev *parallel = backend->parallel;
     int fd;
 
     fd = qmp_chardev_open_file_source(parallel->device, O_RDWR, errp);
     if (fd < 0) {
         return NULL;
     }
-    return qemu_chr_open_pp_fd(fd);
+    return qemu_chr_open_pp_fd(fd, errp);
 }
 #endif
 
@@ -4265,11 +4273,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
         case CHARDEV_BACKEND_KIND_SERIAL:
             abort();
             break;
-#ifdef HAVE_CHARDEV_PARPORT
         case CHARDEV_BACKEND_KIND_PARALLEL:
-            chr = qmp_chardev_open_parallel(backend->parallel, &local_err);
+            abort();
             break;
-#endif
         case CHARDEV_BACKEND_KIND_PIPE:
             chr = qemu_chr_open_pipe(backend->pipe);
             break;
@@ -4405,10 +4411,12 @@ static void register_types(void)
     register_char_driver("tty", CHARDEV_BACKEND_KIND_SERIAL,
                          qemu_chr_parse_serial, qmp_chardev_open_serial);
 #endif
+#ifdef HAVE_CHARDEV_PARPORT
     register_char_driver("parallel", CHARDEV_BACKEND_KIND_PARALLEL,
-                         qemu_chr_parse_parallel, NULL);
+                         qemu_chr_parse_parallel, qmp_chardev_open_parallel);
     register_char_driver("parport", CHARDEV_BACKEND_KIND_PARALLEL,
-                         qemu_chr_parse_parallel, NULL);
+                         qemu_chr_parse_parallel, qmp_chardev_open_parallel);
+#endif
     register_char_driver("pty", CHARDEV_BACKEND_KIND_PTY, NULL,
                          NULL);
     register_char_driver("console", CHARDEV_BACKEND_KIND_CONSOLE, NULL,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16
@ 2015-10-19  8:38 Paolo Bonzini
  2015-10-19  8:38 ` [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation Paolo Bonzini
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Paolo Bonzini @ 2015-10-19  8:38 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 5451316ed07b758a187dedf21047bed8f843f7f1:

  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2015-10-12 15:52:54 +0100)

are available in the git repository at:

  git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 1c4a55dbed9a47fde9294f7de6c8bb060d874c88:

  kvm: Allow the Hyper-V vendor ID to be specified (2015-10-19 10:13:07 +0200)

----------------------------------------------------------------
* KVM page size fix for PPC
* Support for Linux 4.4's new Hyper-V features
* Eliminate g_slice from areas I maintain
* checkpatch fix
* Peter's cpu_reload_memory_map() cleanups
* More changes to MAINTAINERS
* Require Python 2.6
* chardev creation fixes
* PCI requester id for ARM KVM
* cleanups and doc fixes
* Allow customization of the Hyper-V vendor id

----------------------------------------------------------------
Alex Williamson (1):
      kvm: Allow the Hyper-V vendor ID to be specified

Alexey Kardashevskiy (1):
      kvm-all: Align to qemu_real_host_page_size in kvm_set_phys_mem

Andrey Smetanin (3):
      target-i386/kvm: Hyper-V HV_X64_MSR_RESET support
      target-i386/kvm: set Hyper-V features cpuid bit HV_X64_MSR_VP_INDEX_AVAILABLE
      target-i386/kvm: Hyper-V HV_X64_MSR_VP_RUNTIME support

Andy Whitcroft (1):
      checkpatch: port fix from kernel "## is not a valid modifier"

Daniel P. Berrange (1):
      README: fill out some useful quickstart information

Markus Armbruster (1):
      configure: Require Python 2.6

Paolo Bonzini (33):
      nbd: switch from g_slice allocator to malloc
      scsi: switch from g_slice allocator to malloc
      megasas: fix megasas_get_sata_addr
      checkpatch: allow open braces on typedef lines
      linux-headers: update from kvm/next
      exec: remove non-TCG stuff from exec-all.h header.
      MAINTAINERS: add two devices to the e500 section
      MAINTAINERS: Add more Xen files
      MAINTAINERS: Add more pxa2xx files and boards
      MAINTAINERS: Add maintainer for ARM PrimeCell and integrated devices
      MAINTAINERS: Add more devices to realview board
      qemu-sockets: fix conversion of ipv4/ipv6 JSON to QemuOpts
      qemu-char: cleanup qmp_chardev_add
      qemu-char: cleanup HAVE_CHARDEV_*
      qemu-char: add create to register_char_driver
      qemu-char: convert file backend to data-driven creation
      qemu-char: convert serial backend to data-driven creation
      qemu-char: convert parallel backend to data-driven creation
      qemu-char: convert pipe backend to data-driven creation
      qemu-char: convert socket backend to data-driven creation
      qemu-char: convert UDP backend to data-driven creation
      qemu-char: convert pty backend to data-driven creation
      qemu-char: convert null backend to data-driven creation
      qemu-char: convert mux backend to data-driven creation
      qemu-char: convert msmouse backend to data-driven creation
      qemu-char: convert braille backend to data-driven creation
      qemu-char: convert testdev backend to data-driven creation
      qemu-char: convert stdio backend to data-driven creation
      qemu-char: convert console backend to data-driven creation
      qemu-char: convert spice backend to data-driven creation
      qemu-char: convert vc backend to data-driven creation
      qemu-char: convert ringbuf backend to data-driven creation
      qemu-char: cleanup after completed conversion to cd->create

Pavel Fedin (3):
      kvm: Make KVM_CAP_SIGNAL_MSI globally available
      hw/pci: Introduce pci_requester_id()
      kvm: Pass PCI device pointer to MSI routing functions

Peter Maydell (3):
      exec.c: Don't call cpu_reload_memory_map() from cpu_exec_init()
      cpu-exec-common.c: Clarify comment about cpu_reload_memory_map()'s RCU operations
      exec.c: Collect AddressSpace related fields into a CPUAddressSpace struct

Sergey Fedorov (1):
      doc/rcu: fix g_free_rcu() usage example

Thomas Huth (1):
      kvm: Move x86-specific functions into target-i386/kvm.c

 MAINTAINERS                               |  51 +++-
 README                                    | 108 +++++++-
 backends/baum.c                           |  17 +-
 backends/msmouse.c                        |   8 +-
 backends/testdev.c                        |   8 +-
 configure                                 |  12 +-
 cpu-exec-common.c                         |  33 +--
 docs/rcu.txt                              |   2 +-
 exec.c                                    |  57 +++--
 hw/i386/kvm/pci-assign.c                  |  11 +-
 hw/pci/msi.c                              |   2 +-
 hw/pci/pcie_aer.c                         |   2 +-
 hw/scsi/megasas.c                         |   2 +-
 hw/scsi/scsi-bus.c                        |   4 +-
 hw/scsi/virtio-scsi-dataplane.c           |  10 +-
 hw/scsi/virtio-scsi.c                     |  12 +-
 hw/vfio/pci.c                             |  11 +-
 hw/virtio/virtio-pci.c                    |   5 +-
 include/exec/exec-all.h                   |   8 +-
 include/exec/memattrs.h                   |   4 +-
 include/exec/ram_addr.h                   |   1 +
 include/hw/pci/pci.h                      |   5 +
 include/qemu/typedefs.h                   |   1 +
 include/qom/cpu.h                         |   7 +-
 include/standard-headers/asm-x86/hyperv.h |   6 +
 include/sysemu/char.h                     |  18 +-
 include/sysemu/cpus.h                     |   1 +
 include/sysemu/kvm.h                      |  22 +-
 include/ui/qemu-spice.h                   |   2 -
 kvm-all.c                                 |  56 ++---
 kvm-stub.c                                |  10 +-
 linux-headers/asm-arm64/kvm.h             |  37 ++-
 linux-headers/linux/kvm.h                 |  12 +
 nbd.c                                     |   4 +-
 qemu-char.c                               | 395 ++++++++++++++++--------------
 scripts/checkpatch.pl                     |   9 +-
 spice-qemu-char.c                         |  21 +-
 stubs/Makefile.objs                       |   5 -
 stubs/chr-baum-init.c                     |   7 -
 stubs/chr-msmouse.c                       |   7 -
 stubs/chr-testdev.c                       |   7 -
 stubs/qemu-chr-open-spice.c               |  14 --
 stubs/vc-init.c                           |   7 -
 target-arm/kvm.c                          |   2 +-
 target-i386/cpu-qom.h                     |   4 +
 target-i386/cpu.c                         |   4 +
 target-i386/cpu.h                         |   1 +
 target-i386/kvm.c                         |  87 ++++++-
 target-i386/machine.c                     |  20 ++
 target-mips/kvm.c                         |   2 +-
 target-ppc/kvm.c                          |   2 +-
 target-s390x/kvm.c                        |   2 +-
 ui/console.c                              |  11 +-
 ui/gtk.c                                  |   2 +-
 util/qemu-sockets.c                       |   9 +-
 55 files changed, 723 insertions(+), 444 deletions(-)
 delete mode 100644 stubs/chr-baum-init.c
 delete mode 100644 stubs/chr-msmouse.c
 delete mode 100644 stubs/chr-testdev.c
 delete mode 100644 stubs/qemu-chr-open-spice.c
 delete mode 100644 stubs/vc-init.c
-- 
2.5.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation
  2015-10-19  8:38 [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Paolo Bonzini
@ 2015-10-19  8:38 ` Paolo Bonzini
  2015-10-19  8:38 ` [Qemu-devel] [PULL 37/49] qemu-char: convert testdev " Paolo Bonzini
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2015-10-19  8:38 UTC (permalink / raw)
  To: qemu-devel

Conversion to Error * brings better error messages; before:

    qemu-system-x86_64: -chardev id=serial,backend=parallel,path=vl.c: Failed to create chardev

After:

    qemu-system-x86_64: -chardev id=serial,backend=parallel,path=vl.c: not a parallel port: Inappropriate ioctl for device

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-char.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 8567580..ee6381b 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1753,12 +1753,13 @@ static void pp_close(CharDriverState *chr)
     qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
 }
 
-static CharDriverState *qemu_chr_open_pp_fd(int fd)
+static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp)
 {
     CharDriverState *chr;
     ParallelCharDriver *drv;
 
     if (ioctl(fd, PPCLAIM) < 0) {
+        error_setg_errno(errp, errno, "not a parallel port");
         close(fd);
         return NULL;
     }
@@ -1818,7 +1819,7 @@ static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
     return 0;
 }
 
-static CharDriverState *qemu_chr_open_pp_fd(int fd)
+static CharDriverState *qemu_chr_open_pp_fd(int fd, Error **errp)
 {
     CharDriverState *chr;
 
@@ -3481,6 +3482,7 @@ static void qemu_chr_parse_serial(QemuOpts *opts, ChardevBackend *backend,
 }
 #endif
 
+#ifdef HAVE_CHARDEV_PARPORT
 static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend,
                                     Error **errp)
 {
@@ -3493,6 +3495,7 @@ static void qemu_chr_parse_parallel(QemuOpts *opts, ChardevBackend *backend,
     backend->parallel = g_new0(ChardevHostdev, 1);
     backend->parallel->device = g_strdup(device);
 }
+#endif
 
 static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend,
                                 Error **errp)
@@ -4044,13 +4047,6 @@ static CharDriverState *qmp_chardev_open_serial(const char *id,
     return qemu_chr_open_win_path(serial->device, errp);
 }
 
-static CharDriverState *qmp_chardev_open_parallel(ChardevHostdev *parallel,
-                                                  Error **errp)
-{
-    error_setg(errp, "character device backend type 'parallel' not supported");
-    return NULL;
-}
-
 #else /* WIN32 */
 
 static int qmp_chardev_open_file_source(char *src, int flags,
@@ -4110,16 +4106,19 @@ static CharDriverState *qmp_chardev_open_serial(const char *id,
 #endif
 
 #ifdef HAVE_CHARDEV_PARPORT
-static CharDriverState *qmp_chardev_open_parallel(ChardevHostdev *parallel,
+static CharDriverState *qmp_chardev_open_parallel(const char *id,
+                                                  ChardevBackend *backend,
+                                                  ChardevReturn *ret,
                                                   Error **errp)
 {
+    ChardevHostdev *parallel = backend->parallel;
     int fd;
 
     fd = qmp_chardev_open_file_source(parallel->device, O_RDWR, errp);
     if (fd < 0) {
         return NULL;
     }
-    return qemu_chr_open_pp_fd(fd);
+    return qemu_chr_open_pp_fd(fd, errp);
 }
 #endif
 
@@ -4265,11 +4264,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
         case CHARDEV_BACKEND_KIND_SERIAL:
             abort();
             break;
-#ifdef HAVE_CHARDEV_PARPORT
         case CHARDEV_BACKEND_KIND_PARALLEL:
-            chr = qmp_chardev_open_parallel(backend->parallel, &local_err);
+            abort();
             break;
-#endif
         case CHARDEV_BACKEND_KIND_PIPE:
             chr = qemu_chr_open_pipe(backend->pipe);
             break;
@@ -4405,10 +4402,12 @@ static void register_types(void)
     register_char_driver("tty", CHARDEV_BACKEND_KIND_SERIAL,
                          qemu_chr_parse_serial, qmp_chardev_open_serial);
 #endif
+#ifdef HAVE_CHARDEV_PARPORT
     register_char_driver("parallel", CHARDEV_BACKEND_KIND_PARALLEL,
-                         qemu_chr_parse_parallel, NULL);
+                         qemu_chr_parse_parallel, qmp_chardev_open_parallel);
     register_char_driver("parport", CHARDEV_BACKEND_KIND_PARALLEL,
-                         qemu_chr_parse_parallel, NULL);
+                         qemu_chr_parse_parallel, qmp_chardev_open_parallel);
+#endif
     register_char_driver("pty", CHARDEV_BACKEND_KIND_PTY, NULL,
                          NULL);
     register_char_driver("console", CHARDEV_BACKEND_KIND_CONSOLE, NULL,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 37/49] qemu-char: convert testdev backend to data-driven creation
  2015-10-19  8:38 [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Paolo Bonzini
  2015-10-19  8:38 ` [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation Paolo Bonzini
@ 2015-10-19  8:38 ` Paolo Bonzini
  2015-10-19  8:38 ` [Qemu-devel] [PULL 49/49] kvm: Allow the Hyper-V vendor ID to be specified Paolo Bonzini
  2015-10-19 10:45 ` [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2015-10-19  8:38 UTC (permalink / raw)
  To: qemu-devel

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 backends/testdev.c    | 7 +++++--
 include/sysemu/char.h | 3 ---
 qemu-char.c           | 2 +-
 stubs/Makefile.objs   | 1 -
 stubs/chr-testdev.c   | 7 -------
 5 files changed, 6 insertions(+), 14 deletions(-)
 delete mode 100644 stubs/chr-testdev.c

diff --git a/backends/testdev.c b/backends/testdev.c
index 43787f6..26d5c73 100644
--- a/backends/testdev.c
+++ b/backends/testdev.c
@@ -108,7 +108,10 @@ static void testdev_close(struct CharDriverState *chr)
     g_free(testdev);
 }
 
-CharDriverState *chr_testdev_init(void)
+static CharDriverState *chr_testdev_init(const char *id,
+                                         ChardevBackend *backend,
+                                         ChardevReturn *ret,
+                                         Error **errp)
 {
     TestdevCharState *testdev;
     CharDriverState *chr;
@@ -126,7 +129,7 @@ CharDriverState *chr_testdev_init(void)
 static void register_types(void)
 {
     register_char_driver("testdev", CHARDEV_BACKEND_KIND_TESTDEV, NULL,
-                         NULL);
+                         chr_testdev_init);
 }
 
 type_init(register_types);
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index 77415ec..5c28c16 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -356,9 +356,6 @@ extern int term_escape_char;
 
 CharDriverState *qemu_char_get_next_serial(void);
 
-/* testdev.c */
-CharDriverState *chr_testdev_init(void);
-
 /* console.c */
 typedef CharDriverState *(VcHandler)(ChardevVC *vc);
 
diff --git a/qemu-char.c b/qemu-char.c
index f2e3a35..56bc7ed 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -4318,7 +4318,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
             abort();
             break;
         case CHARDEV_BACKEND_KIND_TESTDEV:
-            chr = chr_testdev_init();
+            abort();
             break;
         case CHARDEV_BACKEND_KIND_STDIO:
             chr = qemu_chr_open_stdio(backend->stdio);
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 8cfa5a2..b5322a2 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -1,6 +1,5 @@
 stub-obj-y += arch-query-cpu-def.o
 stub-obj-y += bdrv-commit-all.o
-stub-obj-y += chr-testdev.o
 stub-obj-y += clock-warp.o
 stub-obj-y += cpu-get-clock.o
 stub-obj-y += cpu-get-icount.o
diff --git a/stubs/chr-testdev.c b/stubs/chr-testdev.c
deleted file mode 100644
index 23112a2..0000000
--- a/stubs/chr-testdev.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "qemu-common.h"
-#include "sysemu/char.h"
-
-CharDriverState *chr_testdev_init(void)
-{
-    return 0;
-}
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 49/49] kvm: Allow the Hyper-V vendor ID to be specified
  2015-10-19  8:38 [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Paolo Bonzini
  2015-10-19  8:38 ` [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation Paolo Bonzini
  2015-10-19  8:38 ` [Qemu-devel] [PULL 37/49] qemu-char: convert testdev " Paolo Bonzini
@ 2015-10-19  8:38 ` Paolo Bonzini
  2015-10-19 10:45 ` [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2015-10-19  8:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson

From: Alex Williamson <alex.williamson@redhat.com>

According to Microsoft documentation, the signature in the standard
hypervisor CPUID leaf at 0x40000000 identifies the Vendor ID and is
for reporting and diagnostic purposes only.  We can therefore allow
the user to change it to whatever they want, within the 12 character
limit.  Add a new hv-vendor-id option to the -cpu flag to allow
for this, ex:

 -cpu host,hv_time,hv-vendor-id=KeenlyKVM

Link: http://msdn.microsoft.com/library/windows/hardware/hh975392
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <20151016153356.28104.48612.stgit@gimli.home>
[Adjust error message to match the property name, use error_report. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target-i386/cpu-qom.h |  1 +
 target-i386/cpu.c     |  1 +
 target-i386/kvm.c     | 14 +++++++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 9eab41b..e3bfe9d 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -88,6 +88,7 @@ typedef struct X86CPU {
     bool hyperv_vapic;
     bool hyperv_relaxed_timing;
     int hyperv_spinlock_attempts;
+    char *hyperv_vendor_id;
     bool hyperv_time;
     bool hyperv_crash;
     bool hyperv_reset;
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d2b0619..5f53af2 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -3149,6 +3149,7 @@ static Property x86_cpu_properties[] = {
     DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0),
     DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0),
     DEFINE_PROP_UINT32("xlevel2", X86CPU, env.cpuid_xlevel2, 0),
+    DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor_id),
     DEFINE_PROP_END_OF_LIST()
 };
 
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 010ac51..64046cb 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -28,6 +28,7 @@
 #include "exec/gdbstub.h"
 #include "qemu/host-utils.h"
 #include "qemu/config-file.h"
+#include "qemu/error-report.h"
 #include "hw/i386/pc.h"
 #include "hw/i386/apic.h"
 #include "hw/i386/apic_internal.h"
@@ -505,7 +506,18 @@ int kvm_arch_init_vcpu(CPUState *cs)
     if (hyperv_enabled(cpu)) {
         c = &cpuid_data.entries[cpuid_i++];
         c->function = HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
-        memcpy(signature, "Microsoft Hv", 12);
+        if (!cpu->hyperv_vendor_id) {
+            memcpy(signature, "Microsoft Hv", 12);
+        } else {
+            size_t len = strlen(cpu->hyperv_vendor_id);
+
+            if (len > 12) {
+                error_report("hv-vendor-id truncated to 12 characters");
+                len = 12;
+            }
+            memset(signature, 0, 12);
+            memcpy(signature, cpu->hyperv_vendor_id, len);
+        }
         c->eax = HYPERV_CPUID_MIN;
         c->ebx = signature[0];
         c->ecx = signature[1];
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16
  2015-10-19  8:38 [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2015-10-19  8:38 ` [Qemu-devel] [PULL 49/49] kvm: Allow the Hyper-V vendor ID to be specified Paolo Bonzini
@ 2015-10-19 10:45 ` Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2015-10-19 10:45 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On 19 October 2015 at 09:38, Paolo Bonzini <pbonzini@redhat.com> wrote:
> The following changes since commit 5451316ed07b758a187dedf21047bed8f843f7f1:
>
>   Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2015-10-12 15:52:54 +0100)
>
> are available in the git repository at:
>
>   git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 1c4a55dbed9a47fde9294f7de6c8bb060d874c88:
>
>   kvm: Allow the Hyper-V vendor ID to be specified (2015-10-19 10:13:07 +0200)
>
> ----------------------------------------------------------------
> * KVM page size fix for PPC
> * Support for Linux 4.4's new Hyper-V features
> * Eliminate g_slice from areas I maintain
> * checkpatch fix
> * Peter's cpu_reload_memory_map() cleanups
> * More changes to MAINTAINERS
> * Require Python 2.6
> * chardev creation fixes
> * PCI requester id for ARM KVM
> * cleanups and doc fixes
> * Allow customization of the Hyper-V vendor id
>

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-19 10:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19  8:38 [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Paolo Bonzini
2015-10-19  8:38 ` [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation Paolo Bonzini
2015-10-19  8:38 ` [Qemu-devel] [PULL 37/49] qemu-char: convert testdev " Paolo Bonzini
2015-10-19  8:38 ` [Qemu-devel] [PULL 49/49] kvm: Allow the Hyper-V vendor ID to be specified Paolo Bonzini
2015-10-19 10:45 ` [Qemu-devel] [PULL v2 00/49] Misc patches for 2015-10-16 Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2015-10-16  8:49 [Qemu-devel] [PULL " Paolo Bonzini
2015-10-16  8:49 ` [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).