Re: [PATCH 5/6] tests: handling signal on win32 properly

2020-09-02 Thread Thomas Huth
On 02/09/2020 19.04, Paolo Bonzini wrote:
> On 02/09/20 19:00, Yonggang Luo wrote:
>> SIGABRT should use signal(SIGABRT, sigabrt_handler) to handle on win32
>>
>> The error:
>> E:/CI-Cor-Ready/xemu/qemu.org/tests/test-replication.c:559:33: error: 
>> invalid use of undefined type 'struct sigaction'
>>   559 | sigact = (struct sigaction) {
>>   | ^
>>
>> Signed-off-by: Yonggang Luo 
>> ---
>>  tests/test-replication.c | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/tests/test-replication.c b/tests/test-replication.c
>> index e0b03dafc2..9ab3666a90 100644
>> --- a/tests/test-replication.c
>> +++ b/tests/test-replication.c
>> @@ -554,6 +554,9 @@ static void sigabrt_handler(int signo)
>>  
>>  static void setup_sigabrt_handler(void)
>>  {
>> +#ifdef _WIN32
>> +signal(SIGABRT, sigabrt_handler);
>> +#else
>>  struct sigaction sigact;
>>  
>>  sigact = (struct sigaction) {
>> @@ -562,6 +565,7 @@ static void setup_sigabrt_handler(void)
>>  };
>>  sigemptyset(_mask);
>>  sigaction(SIGABRT, , NULL);
>> +#endif
>>  }
>>  
>>  int main(int argc, char **argv)
>>
> 
> This is already fixed by a patch from Thomas.

Well, my patch was to simply disable test-replication on Windows ... if
it is working with this modification here, that's certainly better than
disabling it.

 Thomas




[Bug 1893758] Re: meson: scary KeyboardInterrupt backtrace displayed

2020-09-02 Thread Paolo Bonzini
That's just how Python works. :-(

https://bugs.python.org/issue14229

** Bug watch added: Python Roundup #14229
   http://bugs.python.org/issue14229

** Changed in: qemu
   Status: New => Won't Fix

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1893758

Title:
  meson: scary KeyboardInterrupt backtrace displayed

Status in QEMU:
  Won't Fix

Bug description:
  Pressing ^C while building (calling 'make') sometime displays
  KeyboardInterrupt exception backtrace (host Fedora 32):

  $ make qemu-system-arm
  Generating qemu-version.h with a meson_exe.py custom command
  ^CTraceback (most recent call last):
File "/usr/bin/meson", line 6, in 
  from pkg_resources import load_entry_point
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3252, in 
  def _initialize_master_working_set():
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3235, in _call_aside
  f(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3277, in _initialize_master_working_set
  tuple(
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3278, in 
  dist.activate(replace=False)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2782, in activate
  fixup_namespace_packages(self.location)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2295, in fixup_namespace_packages
  subpath = _handle_ns(package, path_item)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2194, in _handle_ns
  importer = get_importer(path_item)
File "/usr/lib64/python3.8/pkgutil.py", line 415, in get_importer
  importer = sys.path_importer_cache[path_item]
  KeyboardInterrupt

  
  $ make
  [...]
  Compiling C object libcommon.fa.p/disas_alpha.c.o
  Compiling C object libcommon.fa.p/hw_isa_smc37c669-superio.c.o
  Compiling C object libcommon.fa.p/hw_isa_isa-superio.c.o
  Compiling C object libcommon.fa.p/hw_char_serial-isa.c.o
  Compiling C object libcommon.fa.p/hw_acpi_aml-build-stub.c.o
  ^CTraceback (most recent call last):
File "/usr/bin/meson", line 6, in 
  from pkg_resources import load_entry_point
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3252, in 
  make: *** [Makefile.ninja:994: libcommon.fa.p/disas_alpha.c.o] Interrupt
  make: *** [Makefile.ninja:998: libcommon.fa.p/hw_isa_smc37c669-superio.c.o] 
Interrupt
  make: *** [Makefile.ninja:1025: libcommon.fa.p/hw_isa_isa-superio.c.o] 
Interrupt
  make: *** [Makefile.ninja:1069: libcommon.fa.p/hw_char_serial-isa.c.o] 
Interrupt
  make: *** [Makefile.ninja:1102: libcommon.fa.p/hw_acpi_aml-build-stub.c.o] 
Interrupt
  make: *** [Makefile.ninja:2138: qemu-system-alpha.p/softmmu_main.c.o] 
Interrupt
  make: *** [Makefile.ninja:949: libblock.fa.p/block_qcow2.c.o] Interrupt
  def _initialize_master_working_set():
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3235, in _call_aside
  f(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
3287, in _initialize_master_working_set
  list(map(working_set.add_entry, sys.path))
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
623, in add_entry
  for dist in find_distributions(entry, True):
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2065, in find_on_path
  for dist in factory(fullpath):
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2134, in distributions_from_metadata
  yield Distribution.from_location(
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2590, in from_location
  return cls(
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
2571, in __init__
  self._version = safe_version(version)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 
1331, in safe_version
  return str(packaging.version.Version(version))
File 
"/usr/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py", 
line 205, in __init__
  self._version = _Version(
File "", line 1, in __new__
  KeyboardInterrupt
  make: *** [Makefile.ninja:875: qemu.syms.stamp] Interrupt

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1893758/+subscriptions



Re: [PULL v2 00/15] Cirrus-CI improvements, and other CI-related fixes, m68k

2020-09-02 Thread Gerd Hoffmann
  Hi,

> Darn. I've added Gerd's patch since it is needed to fix the acceptance
> tests in the Gitlab-CI. Could we maybe revert the patch that introduced
> the regression instead, as long as no other proper fix is available? The
> failing CI is really bugging me.

Well, ddcf607fa3d6 fixes another nasty issue (builds modifying the
source tree), so reverting that isn't really an option.

We could have configure remove the symlink in case is present.  That way
old build trees with the symlink already created should work too.  Right
now only build trees created with ddcf607fa3d6 present are working
properly.

Untested patch below.

take care,
  Gerd

diff --git a/configure b/configure
index b1e11397a827..493b4e86da62 100755
--- a/configure
+++ b/configure
@@ -8107,6 +8107,7 @@ LINKS="$LINKS .gdbinit scripts" # scripts needed by 
relative path in .gdbinit
 LINKS="$LINKS tests/acceptance tests/data"
 LINKS="$LINKS tests/qemu-iotests/check"
 LINKS="$LINKS python"
+UNLINK="pc-bios/keymaps"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.elf \
@@ -8127,6 +8128,11 @@ for f in $LINKS ; do
 symlink "$source_path/$f" "$f"
 fi
 done
+for f in $UNLINK ; do
+if [ -L "$f" ]; then
+rm -f "$f"
+fi
+done
 
 (for i in $cross_cc_vars; do
   export $i




[PATCH] stubs: Move qemu_fd_register stub to util/main-loop.c

2020-09-02 Thread Thomas Huth
The linker of MinGW sometimes runs into the following problem:

libqemuutil.a(util_main-loop.c.obj): In function `qemu_fd_register':
/builds/huth/qemu/build/../util/main-loop.c:331: multiple definition of
 `qemu_fd_register'
libqemuutil.a(stubs_fd-register.c.obj):/builds/huth/qemu/stubs/fd-register.c:5:
 first defined here
collect2: error: ld returned 1 exit status
/builds/huth/qemu/rules.mak:88: recipe for target 'tests/test-timed-average.exe'
 failed

qemu_fd_register() is defined in util/main-loop.c for WIN32, so let's simply
move the stub also there in the #else part of the corresponding #ifndef
to fix this problem.

Signed-off-by: Thomas Huth 
---
 stubs/fd-register.c | 6 --
 stubs/meson.build   | 1 -
 util/main-loop.c| 4 
 3 files changed, 4 insertions(+), 7 deletions(-)
 delete mode 100644 stubs/fd-register.c

diff --git a/stubs/fd-register.c b/stubs/fd-register.c
deleted file mode 100644
index 63a4abdb20..00
--- a/stubs/fd-register.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "qemu/osdep.h"
-#include "qemu/main-loop.h"
-
-void qemu_fd_register(int fd)
-{
-}
diff --git a/stubs/meson.build b/stubs/meson.build
index e2dfedc2a7..e0b322bc28 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -9,7 +9,6 @@ stub_ss.add(files('cpu-get-clock.c'))
 stub_ss.add(files('cpu-get-icount.c'))
 stub_ss.add(files('dump.c'))
 stub_ss.add(files('error-printf.c'))
-stub_ss.add(files('fd-register.c'))
 stub_ss.add(files('fdset.c'))
 stub_ss.add(files('fw_cfg.c'))
 stub_ss.add(files('gdbstub.c'))
diff --git a/util/main-loop.c b/util/main-loop.c
index f69f055013..217c8d6056 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -179,6 +179,10 @@ static int max_priority;
 static int glib_pollfds_idx;
 static int glib_n_poll_fds;
 
+void qemu_fd_register(int fd)
+{
+}
+
 static void glib_pollfds_fill(int64_t *cur_timeout)
 {
 GMainContext *context = g_main_context_default();
-- 
2.18.2




Re: [PATCH v1 3/6] net/can: Add can_dlc2len and can_len2dlc for CAN FD.

2020-09-02 Thread Vikram Garhwal
On Tue, Jul 14, 2020 at 02:20:16PM +0200, p...@cmp.felk.cvut.cz wrote:
Hi Pavel,
> From: Jan Charvat 
>
> Signed-off-by: Jan Charvat 
> Signed-off-by: Pavel Pisa 
> ---
>  include/net/can_emu.h |  4 
>  net/can/can_core.c| 36 
>  2 files changed, 40 insertions(+)
>
> diff --git a/include/net/can_emu.h b/include/net/can_emu.h
> index c6164dcfb4..7d395fbb9b 100644
> --- a/include/net/can_emu.h
> +++ b/include/net/can_emu.h
> @@ -127,4 +127,8 @@ int can_bus_client_set_filters(CanBusClientState *,
> const struct qemu_can_filter *filters,
> size_t filters_cnt);
>
> +uint8_t can_dlc2len(uint8_t can_dlc);
> +
> +uint8_t can_len2dlc(uint8_t len);
> +
These function are aimed for canfd. Perhaps rename these to canfd_dlc2len and
canfd_len2dlc for better distinction?
Rest of the patch looks good to me.
>  #endif
> diff --git a/net/can/can_core.c b/net/can/can_core.c
> index 90f4d8576a..0115d78794 100644
> --- a/net/can/can_core.c
> +++ b/net/can/can_core.c
> @@ -33,6 +33,42 @@
>  #include "net/can_emu.h"
>  #include "qom/object_interfaces.h"
>
> +/* CAN DLC to real data length conversion helpers */
> +
> +static const uint8_t dlc2len[] = {
> +0, 1, 2, 3, 4, 5, 6, 7,
> +8, 12, 16, 20, 24, 32, 48, 64
> +};
> +
> +/* get data length from can_dlc with sanitized can_dlc */
> +uint8_t can_dlc2len(uint8_t can_dlc)
> +{
> +return dlc2len[can_dlc & 0x0F];
> +}
> +
> +static const uint8_t len2dlc[] = {
> +0, 1, 2, 3, 4, 5, 6, 7, 8,  /* 0 - 8 */
> +9, 9, 9, 9, /* 9 - 12 */
> +10, 10, 10, 10, /* 13 - 16 */
> +11, 11, 11, 11, /* 17 - 20 */
> +12, 12, 12, 12, /* 21 - 24 */
> +13, 13, 13, 13, 13, 13, 13, 13, /* 25 - 32 */
> +14, 14, 14, 14, 14, 14, 14, 14, /* 33 - 40 */
> +14, 14, 14, 14, 14, 14, 14, 14, /* 41 - 48 */
> +15, 15, 15, 15, 15, 15, 15, 15, /* 49 - 56 */
> +15, 15, 15, 15, 15, 15, 15, 15  /* 57 - 64 */
> +};
> +
> +/* map the sanitized data length to an appropriate data length code */
> +uint8_t can_len2dlc(uint8_t len)
> +{
> +if (unlikely(len > 64)) {
> +return 0xF;
> +}
> +
> +return len2dlc[len];
> +}
> +
>  struct CanBusState {
>  Object object;
>
> --
> 2.20.1
>
>



Re: [PATCH v1 1/6] net/can: Initial host SocketCan support for CAN FD.

2020-09-02 Thread Vikram Garhwal
On Wed, Sep 02, 2020 at 09:51:44AM +0200, Pavel Pisa wrote:
Hi Pavel,
> Hello Vikram,
>
> thanks much for the patches review.
>
> On Tuesday 01 of September 2020 22:01:26 Vikram Garhwal wrote:
> > Hi Jan,
> > A couple of comments on this patch.
> >
> > On Tue, Jul 14, 2020 at 02:20:14PM +0200, p...@cmp.felk.cvut.cz wrote:
> > > From: Jan Charvat 
> > > @@ -185,13 +204,34 @@ static void can_host_socketcan_connect(CanHostState
> > > *ch, Error **errp) addr.can_family = AF_CAN;
> > >  memset(_name, 0, sizeof(ifr.ifr_name));
> > >  strcpy(ifr.ifr_name, c->ifname);
> > > +/* check if the frame fits into the CAN netdevice */
> > >  if (ioctl(s, SIOCGIFINDEX, ) < 0) {
> > >  error_setg_errno(errp, errno,
> > > - "SocketCAN host interface %s not available",
> > > c->ifname); + "SocketCAN host interface %s not
> > > available", + c->ifname);
> >
> > May be this formatting change in a different patch? As this is not related
> > to CANFD.
> > > @@ -232,7 +272,8 @@ static char *can_host_socketcan_get_if(Object *obj,
> > > Error **errp) return g_strdup(c->ifname);
> > >  }
> > >
> > > -static void can_host_socketcan_set_if(Object *obj, const char *value,
> > > Error **errp) +static void can_host_socketcan_set_if(Object *obj, const
> > > char *value,
> > > +  Error **errp)
> >
> > This one also not relevant change for CANFD. Rest of the patch looks good.
>
>
> I am responsible for mentioned lines change in net/can/can_socketcan.c.
> When I have reviewed patches after Jan Charvat theses submittion,
> I have done another bunch of rounds to check that the patches as well
> as the whole net/can and hw/net/can are checkpatch clean. I am not sure
> if the incorrect formatting sneaked in in my 2018 submission or patcheck
> became more strict last years.
>
> I can separate these changes changes into separate patch if required.
May be we can keep them in same patch. I was just referring to "Don't include 
irrelevant changes" section on this page about patches: 
https://wiki.qemu.org/Contribute/SubmitAPatch.
>
> By the way, if you or other of your colleagues is willing to participate
> in net/can and or  hw/net/can patches reviews, I would be happy if you
> join my attempt and we can record that we are available to take care
> abut these in MAINTAINERS file.
Given that I spent good amount of time working with net/can, I am willing to 
review the patches. Thanks!
>
> Best wishes,
>
> Pavel
>
>



Re: [PATCH] usb-host: workaround libusb bug

2020-09-02 Thread Gerd Hoffmann
On Wed, Sep 02, 2020 at 03:31:46PM +0100, Alex Bennée wrote:
> 
> Gerd Hoffmann  writes:
> 
> >> > +#include 
> >
> >> > +int rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL);
> >> 
> >> This (further) breaks a bunch of the Travis jobs - I assume because libusb 
> >> doesn't
> >> always have this symbol:
> >> 
> >>   ../hw/usb/host-libusb.c:954:32: error: ‘USBDEVFS_GET_SPEED’ undeclared 
> >> (first use in this function)
> >
> > It isn't libusb, it is the kernel (linux/usbdevice_fs.h).
> >
> > /me checks git ...
> > Added in 4.13, so available for quite a while.
> > I guess that is the prehistoric ubuntu version travis has?
> >
> > Given that we only need that workaround with rather new libusb versions
> > (which have libusb_wrap_sys_device() support) which most likely isn't
> > present in that old ubuntu version we can probably just do this:
> >
> > diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
> > index 08604f787fdf..c25102f3aca1 100644
> > --- a/hw/usb/host-libusb.c
> > +++ b/hw/usb/host-libusb.c
> > @@ -942,7 +942,7 @@ static int usb_host_open(USBHostDevice *s, 
> > libusb_device *dev, int hostfd)
> >  usb_host_ep_update(s);
> >  
> >  libusb_speed = libusb_get_device_speed(dev);
> > -#ifdef CONFIG_LINUX
> > +#if LIBUSB_API_VERSION >= 0x01000107 && defined(CONFIG_LINUX)
> >  if (hostfd && libusb_speed == 0) {
> >  /*
> >   * Workaround libusb bug: libusb_get_device_speed() does not
> 
> That works. Do you want to include that in your next PR or send a patch
> for me to include in my testing/next PR?

Patch is on the list already:
https://patchwork.ozlabs.org/project/qemu-devel/patch/20200902081445.3291-1-kra...@redhat.com/

Feel free to include it in testing pull.

take care,
  Gerd




RE: [PATCH v1 1/6] net/can: Initial host SocketCan support for CAN FD.

2020-09-02 Thread Vikram Garhwal
Hi Pavel,
Forgot to add this in last reply: Francisco Iglesias(in cc) was also involved a 
lot in net/can QEMU devices and willing to help in the review if needed. 

Regards
Vikram

> -Original Message-
> From: Vikram Garhwal 
> Sent: Wednesday, September 2, 2020 10:20 PM
> To: Pavel Pisa 
> Cc: qemu-devel@nongnu.org; Paolo Bonzini ;
> Stefan Hajnoczi ; Konrad Frederic
> ; Deniz Eren ;
> Oliver Hartkopp ; Marek Vasut
> ; Jan Kiszka ; Oleksij Rempel
> ; Markus Armbruster ;
> Ondrej Ille ; Jan Charvat ;
> Jiri Novak 
> Subject: Re: [PATCH v1 1/6] net/can: Initial host SocketCan support for CAN
> FD.
> 
> On Wed, Sep 02, 2020 at 09:51:44AM +0200, Pavel Pisa wrote:
> Hi Pavel,
> > Hello Vikram,
> >
> > thanks much for the patches review.
> >
> > On Tuesday 01 of September 2020 22:01:26 Vikram Garhwal wrote:
> > > Hi Jan,
> > > A couple of comments on this patch.
> > >
> > > On Tue, Jul 14, 2020 at 02:20:14PM +0200, p...@cmp.felk.cvut.cz
> wrote:
> > > > From: Jan Charvat  @@ -185,13 +204,34 @@
> > > > static void can_host_socketcan_connect(CanHostState
> > > > *ch, Error **errp) addr.can_family = AF_CAN;
> > > >  memset(_name, 0, sizeof(ifr.ifr_name));
> > > >  strcpy(ifr.ifr_name, c->ifname);
> > > > +/* check if the frame fits into the CAN netdevice */
> > > >  if (ioctl(s, SIOCGIFINDEX, ) < 0) {
> > > >  error_setg_errno(errp, errno,
> > > > - "SocketCAN host interface %s not available",
> > > > c->ifname); + "SocketCAN host interface %s not
> > > > available", + c->ifname);
> > >
> > > May be this formatting change in a different patch? As this is not
> > > related to CANFD.
> > > > @@ -232,7 +272,8 @@ static char
> *can_host_socketcan_get_if(Object
> > > > *obj, Error **errp) return g_strdup(c->ifname);  }
> > > >
> > > > -static void can_host_socketcan_set_if(Object *obj, const char
> > > > *value, Error **errp) +static void
> > > > can_host_socketcan_set_if(Object *obj, const char *value,
> > > > +  Error **errp)
> > >
> > > This one also not relevant change for CANFD. Rest of the patch looks
> good.
> >
> >
> > I am responsible for mentioned lines change in net/can/can_socketcan.c.
> > When I have reviewed patches after Jan Charvat theses submittion, I
> > have done another bunch of rounds to check that the patches as well as
> > the whole net/can and hw/net/can are checkpatch clean. I am not sure
> > if the incorrect formatting sneaked in in my 2018 submission or
> > patcheck became more strict last years.
> >
> > I can separate these changes changes into separate patch if required.
> May be we can keep them in same patch. I was just referring to "Don't
> include irrelevant changes" section on this page about patches:
> https://wiki.qemu.org/Contribute/SubmitAPatch.
> >
> > By the way, if you or other of your colleagues is willing to
> > participate in net/can and or  hw/net/can patches reviews, I would be
> > happy if you join my attempt and we can record that we are available
> > to take care abut these in MAINTAINERS file.
> Given that I spent good amount of time working with net/can, I am willing
> to review the patches. Thanks!
> >
> > Best wishes,
> >
> > Pavel
> >
> >


Re: meson: how to determine which directory applies to the c_args during build?

2020-09-02 Thread Paolo Bonzini
Il gio 3 set 2020, 06:43 Bin Meng  ha scritto:

> It seems to me that when building hw/char directory NEED_CPU_H is not
> defined. However when building hw/riscv and hw/intc NEED_CPU_H is
> defined. I have no clue where to control c_args to build sub-directories.
> Any suggestions?


Hi!

The common_ss sourceset (and most others: block_ss, softmmu_ss, etc.) will
not have NEED_CPU_H; only specific_ss will, in addition to the entire
directories hw/riscv and target/riscv.

In other words, specific_ss is equivalent to the old obj-y Makefile
variable.

Thanks,


Paolo


[Bug 1894029] Re: qemu-i386 malloc error

2020-09-02 Thread Michael Tokarev
Please stop asking questions using a bug tracking system, this is rude.

No it is not a bug, it appears you can't do simple arithmetics, -- the
pointer is increased by 16 bytes not 2.

** Changed in: qemu
   Status: New => Invalid

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1894029

Title:
  qemu-i386 malloc error

Status in QEMU:
  Invalid

Bug description:
  Hi!I use qemu-i386-static on 64 bit machines.And memory request succeeded, 
but the pointer is wrong.
  This is my test program:

  #include 
  #include 
  #include 
  #include 

  int main(int argc, char **argv)
  {
  void *pa=0,*pb=0,*pc=0,*pd=0;
  pa = malloc(sizeof(uint32_t));
  pb = malloc(sizeof(uint32_t));
  pc = malloc(4);
  pd = malloc(4);
  printf("pa: 0x%x\n",pa);
  printf("pb: 0x%x\n",pb);
  printf("pc: 0x%x\n",pc);
  printf("pd: 0x%x\n",pd);
  printf("uint32_t:%d\n",sizeof(uint32_t));
  free(pa);
  free(pb);
  free(pc);
  free(pd);
  return 0;
  }

  And it is wrong:

  pa: 0x400051a0
  pb: 0x400051b0
  pc: 0x400051c0
  pd: 0x400051d0
  uint32_t:4

  Why did I apply for 4 bytes of space, but the pointer only increased by 2 
bytes??
  Is it a BUG??

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1894029/+subscriptions



Re: [RFC 3/3] virtio-gpu: make the IO handler reentrant

2020-09-02 Thread Michael Tokarev
02.09.2020 19:22, Li Qiang wrote:
..
> @@ -809,6 +809,10 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
>  {
>  struct virtio_gpu_ctrl_command *cmd;
>  
> +if (atomic_read(>in_io)) {
> +return;
> +}
> +atomic_set(>in_io, 1);

Can't we race in these two instructions? Both
threads atomic_reads at the same time, both see zero,
and both are trying to set it to 1, no?

Just asking really, b/c despite of the atomic_ prefix,
to me this look a bit unsafe..

Thanks,

/mjt



Re: [PULL v2 00/15] Cirrus-CI improvements, and other CI-related fixes, m68k

2020-09-02 Thread Thomas Huth
On 02/09/2020 22.19, Peter Maydell wrote:
> On Wed, 2 Sep 2020 at 16:49, Thomas Huth  wrote:
>>
>>  Hi Peter,
>>
>> the following changes since commit 887adde81d1f1f3897f1688d37ec6851b4fdad86:
>>
>>   Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' 
>> into staging (2020-09-01 22:50:23 +0100)
>>
>> are available in the Git repository at:
>>
>>   https://gitlab.com/huth/qemu.git tags/pull-request-2020-09-02
>>
>> for you to fetch changes up to 5e560e07ca396e16150740ae3c46b35a85f59ba7:
>>
>>   gitlab-ci.yml: Set artifacts expiration time (2020-09-02 16:23:55 +0200)
>>
>> 
>> * Cirrus-CI improvements and fixes (compile with -Werror & fix for 1h 
>> problem)
>> * Two build system fixes to fix some failures the CI
>> * One m68k QOMification patch
>> * Some trivial qtest patches
>> * Some small improvements for the Gitlab CI
>> 
> 
> Failures on windows crossbuild and OSX:
> 
> Generating qemu-version.h with a meson_exe.py custom command
> Generating ar with a custom command
> cp: '../../pc-bios/keymaps/ar' and 'pc-bios/keymaps/ar' are the same file
> Generating bepo with a custom command
> cp: '../../pc-bios/keymaps/bepo' and 'pc-bios/keymaps/bepo' are the same file
> Makefile.ninja:5177: recipe for target 'pc-bios/keymaps/ar.stamp' failed
[...]
> This is the same set of errors I got from when Gerd put
> the "meson: fix keymaps witout qemu-keymap" patch in his UI pullreq:
>   https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg00149.html
> so that seems like the problem.

Darn. I've added Gerd's patch since it is needed to fix the acceptance
tests in the Gitlab-CI. Could we maybe revert the patch that introduced
the regression instead, as long as no other proper fix is available? The
failing CI is really bugging me.

 Thomas




Re: [RFC 0/3] try to solve the DMA to MMIO issue

2020-09-02 Thread Li Qiang
Jason Wang  于2020年9月3日周四 下午12:24写道:
>
>
> On 2020/9/3 下午12:06, Alexander Bulekov wrote:
> > On 200903 1154, Jason Wang wrote:
> >> On 2020/9/3 上午12:22, Li Qiang wrote:
> >>> The qemu device fuzzer has found several DMA to MMIO issue.
> >>> These issues is caused by the guest driver programs the DMA
> >>> address, then in the device MMIO handler it trigger the DMA
> >>> and as the DMA address is MMIO it will trigger another dispatch
> >>> and reenter the MMIO handler again. However most of the device
> >>> is not reentrant.
> >>>
> >>> DMA to MMIO will cause issues depend by the device emulator,
> >>> mostly it will crash the qemu. Following is three classic
> >>> DMA to MMIO issue.
> >>>
> >>> e1000e: https://bugs.launchpad.net/qemu/+bug/1886362
> >>> xhci: https://bugs.launchpad.net/qemu/+bug/1891354
> >>> virtio-gpu: https://bugs.launchpad.net/qemu/+bug/1888606
> >>>
> >>> The DMA to MMIO issue I think can be classified as following:
> >>> 1. DMA to the device itself
> >>> 2. device A DMA to device B and to device C
> >>> 3. device A DMA to device B and to device A
> >>>
> >>> The first case of course should not be allowed.
> >>> The second case I think it ok as the device IO handler has no
> >>> assumption about the IO data came from no matter it come from
> >>> device or other device. This is for P2P DMA.
> >>> The third case I think it also should not be allowed.
> >>>
> >>> So our issue has been reduced by one case: not allowed the
> >>> device's IO handler reenter.
> >>>
> >>> Paolo suggested that we can refactor the device emulation with
> >>> BH. However it is a lot of work.
> >>> I have thought several propose to address this, also discuss
> >>> this with Jason Wang in private email.
> >>>
> >>> I have can solve this issue in core framework or in specific device.
> >>> After try several methods I choose address it in per-device for
> >>> following reason:
> >>> 1. If we address it in core framwork we have to recored and check the
> >>> device or MR info in MR dispatch write function. Unfortunally we have
> >>> no these info in core framework.
> >>> 2. The performance will also be decrease largely
> >>> 3. Only the device itself know its IO
> >>
> >> I think we still need to seek a way to address this issue completely.
> >>
> >> How about adding a flag in MemoryRegionOps and detect the reentrancy 
> >> through
> >> that flag?
> > What happens for devices with multiple MemoryRegions? Make all the
> > MemoryRegionOps share the same flag?
>
>
> I think there could be two approaches:
>
> 1) record the device in MR as Qiang mentioned

I have tried this as we discussed. But has following consideration:
1. The performance, we need to check/record/clean the MR in an array/hashtable.

2. The multiple MR and alias MR process in the memory layer. It is
complicated and performance effective.
So If we let the MR issue to the device itself, it is just as this
patch does-let the device address the reentrancy issue.f

Another solution. We connects a MR with the corresponding device. Now
the device often tight MR with an 'opaque' field.
Just uses it in the calling of MR callback. Then we add a flag in the
device and needs to modify the MR register interface.

So in the memory layer we can check/record/clean the MR->device->flag.
But this is can't address the DMA (in BH) to MMIO issue as the BH runs
in main thread.

Thanks,
Li Qiang



> 2) Only forbid the reentrancy in MMIO handler and depends on the device
> to solve the multiple Memory Region issue, if the regions want to access
> the same data, it needs to be synchronized internally
>
> But the point is still to try to solve it in the layer of memory
> regions. Otherwise we may still hit similar issues.
>
>
> >
> > What about the virtio-gpu bug, where the problem happens in a bh->mmio
> > access rather than an mmio->mmio access?
>
>
> Yes, it needs more thought, but as a first step, we can try to fix the
> MMIO handler issue and do bh fix on top.



>
> Thanks
>
>
> >
> > -Alex
> >
> >> Thanks
> >>
> >>
> >>> The (most of the) device emulation is protected by BQL one time only
> >>> a device emulation code can be run. We can add a flag to indicate the
> >>> IO is running. The first two patches does this. For simplicity at the
> >>> RFC stage I just set it while enter the IO callback and clear it exit
> >>> the IO callback. It should be check/set/clean according the per-device's
> >>> IO emulation.
> >>> The second issue which itself suffers a race condition so I uses a
> >>> atomic.
> >>>
> >>>
> >>>
> >>>
> >>> Li Qiang (3):
> >>> e1000e: make the IO handler reentrant
> >>> xhci: make the IO handler reentrant
> >>> virtio-gpu: make the IO handler reentrant
> >>>
> >>>hw/display/virtio-gpu.c| 10 ++
> >>>hw/net/e1000e.c| 35 +++-
> >>>hw/usb/hcd-xhci.c  | 60 ++
> >>>hw/usb/hcd-xhci.h  |  1 +
> >>>include/hw/virtio/virtio-gpu.h |  1 

meson: how to determine which directory applies to the c_args during build?

2020-09-02 Thread Bin Meng
Hi,

I want to move a RISC-V model from hw/riscv directory to hw/uart
directory. The C file includes "target/riscv/cpu.h", but it fails to
compile:

include/exec/cpu-defs.h:23:2: error: #error cpu.h included from common code
 #error cpu.h included from common code
  ^
In file included from include/exec/cpu-defs.h:29:0,
 from target/riscv/cpu.h:25,

...

tcg/i386/tcg-target.h:140:42: error: attempt to use poisoned "TARGET_LONG_BITS"
 #define TCG_TARGET_HAS_extrl_i64_i32(TARGET_LONG_BITS == 32)
  ^
tcg/i386/tcg-target.h:141:42: error: attempt to use poisoned "TARGET_LONG_BITS"
 #define TCG_TARGET_HAS_extrh_i64_i32(TARGET_LONG_BITS == 32)
  ^

It seems to me that when building hw/char directory NEED_CPU_H is not
defined. However when building hw/riscv and hw/intc NEED_CPU_H is
defined. I see NEED_CPU_H is defined in c_args in meson.build:

  c_args = ['-DNEED_CPU_H',
'-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
'-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]

Currently codes in hw/riscv and hw/intc have the "target/riscv/cpu.h"
inclusion but they do build fine. This seems to me that c_args applies
to hw/riscv and hw/intc directory but not hw/char. I also tried other
directories like hw/dma and it didn't work either.

I have no clue where to control c_args to build sub-directories. Any
suggestions?

Regards,
Bin



Re: [RFC 0/3] try to solve the DMA to MMIO issue

2020-09-02 Thread Jason Wang



On 2020/9/3 下午12:06, Alexander Bulekov wrote:

On 200903 1154, Jason Wang wrote:

On 2020/9/3 上午12:22, Li Qiang wrote:

The qemu device fuzzer has found several DMA to MMIO issue.
These issues is caused by the guest driver programs the DMA
address, then in the device MMIO handler it trigger the DMA
and as the DMA address is MMIO it will trigger another dispatch
and reenter the MMIO handler again. However most of the device
is not reentrant.

DMA to MMIO will cause issues depend by the device emulator,
mostly it will crash the qemu. Following is three classic
DMA to MMIO issue.

e1000e: https://bugs.launchpad.net/qemu/+bug/1886362
xhci: https://bugs.launchpad.net/qemu/+bug/1891354
virtio-gpu: https://bugs.launchpad.net/qemu/+bug/1888606

The DMA to MMIO issue I think can be classified as following:
1. DMA to the device itself
2. device A DMA to device B and to device C
3. device A DMA to device B and to device A

The first case of course should not be allowed.
The second case I think it ok as the device IO handler has no
assumption about the IO data came from no matter it come from
device or other device. This is for P2P DMA.
The third case I think it also should not be allowed.

So our issue has been reduced by one case: not allowed the
device's IO handler reenter.

Paolo suggested that we can refactor the device emulation with
BH. However it is a lot of work.
I have thought several propose to address this, also discuss
this with Jason Wang in private email.

I have can solve this issue in core framework or in specific device.
After try several methods I choose address it in per-device for
following reason:
1. If we address it in core framwork we have to recored and check the
device or MR info in MR dispatch write function. Unfortunally we have
no these info in core framework.
2. The performance will also be decrease largely
3. Only the device itself know its IO


I think we still need to seek a way to address this issue completely.

How about adding a flag in MemoryRegionOps and detect the reentrancy through
that flag?

What happens for devices with multiple MemoryRegions? Make all the
MemoryRegionOps share the same flag?



I think there could be two approaches:

1) record the device in MR as Qiang mentioned
2) Only forbid the reentrancy in MMIO handler and depends on the device 
to solve the multiple Memory Region issue, if the regions want to access 
the same data, it needs to be synchronized internally


But the point is still to try to solve it in the layer of memory 
regions. Otherwise we may still hit similar issues.





What about the virtio-gpu bug, where the problem happens in a bh->mmio
access rather than an mmio->mmio access?



Yes, it needs more thought, but as a first step, we can try to fix the 
MMIO handler issue and do bh fix on top.


Thanks




-Alex


Thanks



The (most of the) device emulation is protected by BQL one time only
a device emulation code can be run. We can add a flag to indicate the
IO is running. The first two patches does this. For simplicity at the
RFC stage I just set it while enter the IO callback and clear it exit
the IO callback. It should be check/set/clean according the per-device's
IO emulation.
The second issue which itself suffers a race condition so I uses a
atomic.




Li Qiang (3):
e1000e: make the IO handler reentrant
xhci: make the IO handler reentrant
virtio-gpu: make the IO handler reentrant

   hw/display/virtio-gpu.c| 10 ++
   hw/net/e1000e.c| 35 +++-
   hw/usb/hcd-xhci.c  | 60 ++
   hw/usb/hcd-xhci.h  |  1 +
   include/hw/virtio/virtio-gpu.h |  1 +
   5 files changed, 106 insertions(+), 1 deletion(-)






[Bug 1894029] [NEW] qemu-i386 malloc error

2020-09-02 Thread Tony.LI
Public bug reported:

Hi!I use qemu-i386-static on 64 bit machines.And memory request succeeded, but 
the pointer is wrong.
This is my test program:

#include 
#include 
#include 
#include 

int main(int argc, char **argv)
{
void *pa=0,*pb=0,*pc=0,*pd=0;
pa = malloc(sizeof(uint32_t));
pb = malloc(sizeof(uint32_t));
pc = malloc(4);
pd = malloc(4);
printf("pa: 0x%x\n",pa);
printf("pb: 0x%x\n",pb);
printf("pc: 0x%x\n",pc);
printf("pd: 0x%x\n",pd);
printf("uint32_t:%d\n",sizeof(uint32_t));
free(pa);
free(pb);
free(pc);
free(pd);
return 0;
}

And it is wrong:

pa: 0x400051a0
pb: 0x400051b0
pc: 0x400051c0
pd: 0x400051d0
uint32_t:4

Why did I apply for 4 bytes of space, but the pointer only increased by 2 
bytes??
Is it a BUG??

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1894029

Title:
  qemu-i386 malloc error

Status in QEMU:
  New

Bug description:
  Hi!I use qemu-i386-static on 64 bit machines.And memory request succeeded, 
but the pointer is wrong.
  This is my test program:

  #include 
  #include 
  #include 
  #include 

  int main(int argc, char **argv)
  {
  void *pa=0,*pb=0,*pc=0,*pd=0;
  pa = malloc(sizeof(uint32_t));
  pb = malloc(sizeof(uint32_t));
  pc = malloc(4);
  pd = malloc(4);
  printf("pa: 0x%x\n",pa);
  printf("pb: 0x%x\n",pb);
  printf("pc: 0x%x\n",pc);
  printf("pd: 0x%x\n",pd);
  printf("uint32_t:%d\n",sizeof(uint32_t));
  free(pa);
  free(pb);
  free(pc);
  free(pd);
  return 0;
  }

  And it is wrong:

  pa: 0x400051a0
  pb: 0x400051b0
  pc: 0x400051c0
  pd: 0x400051d0
  uint32_t:4

  Why did I apply for 4 bytes of space, but the pointer only increased by 2 
bytes??
  Is it a BUG??

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1894029/+subscriptions



Re: [RFC 0/3] try to solve the DMA to MMIO issue

2020-09-02 Thread Alexander Bulekov
On 200903 1154, Jason Wang wrote:
> 
> On 2020/9/3 上午12:22, Li Qiang wrote:
> > The qemu device fuzzer has found several DMA to MMIO issue.
> > These issues is caused by the guest driver programs the DMA
> > address, then in the device MMIO handler it trigger the DMA
> > and as the DMA address is MMIO it will trigger another dispatch
> > and reenter the MMIO handler again. However most of the device
> > is not reentrant.
> > 
> > DMA to MMIO will cause issues depend by the device emulator,
> > mostly it will crash the qemu. Following is three classic
> > DMA to MMIO issue.
> > 
> > e1000e: https://bugs.launchpad.net/qemu/+bug/1886362
> > xhci: https://bugs.launchpad.net/qemu/+bug/1891354
> > virtio-gpu: https://bugs.launchpad.net/qemu/+bug/1888606
> > 
> > The DMA to MMIO issue I think can be classified as following:
> > 1. DMA to the device itself
> > 2. device A DMA to device B and to device C
> > 3. device A DMA to device B and to device A
> > 
> > The first case of course should not be allowed.
> > The second case I think it ok as the device IO handler has no
> > assumption about the IO data came from no matter it come from
> > device or other device. This is for P2P DMA.
> > The third case I think it also should not be allowed.
> > 
> > So our issue has been reduced by one case: not allowed the
> > device's IO handler reenter.
> > 
> > Paolo suggested that we can refactor the device emulation with
> > BH. However it is a lot of work.
> > I have thought several propose to address this, also discuss
> > this with Jason Wang in private email.
> > 
> > I have can solve this issue in core framework or in specific device.
> > After try several methods I choose address it in per-device for
> > following reason:
> > 1. If we address it in core framwork we have to recored and check the
> > device or MR info in MR dispatch write function. Unfortunally we have
> > no these info in core framework.
> > 2. The performance will also be decrease largely
> > 3. Only the device itself know its IO
> 
> 
> I think we still need to seek a way to address this issue completely.
> 
> How about adding a flag in MemoryRegionOps and detect the reentrancy through
> that flag?

What happens for devices with multiple MemoryRegions? Make all the
MemoryRegionOps share the same flag?

What about the virtio-gpu bug, where the problem happens in a bh->mmio
access rather than an mmio->mmio access?

-Alex

> Thanks
> 
> 
> > 
> > The (most of the) device emulation is protected by BQL one time only
> > a device emulation code can be run. We can add a flag to indicate the
> > IO is running. The first two patches does this. For simplicity at the
> > RFC stage I just set it while enter the IO callback and clear it exit
> > the IO callback. It should be check/set/clean according the per-device's
> > IO emulation.
> > The second issue which itself suffers a race condition so I uses a
> > atomic.
> > 
> > 
> > 
> > 
> > Li Qiang (3):
> >e1000e: make the IO handler reentrant
> >xhci: make the IO handler reentrant
> >virtio-gpu: make the IO handler reentrant
> > 
> >   hw/display/virtio-gpu.c| 10 ++
> >   hw/net/e1000e.c| 35 +++-
> >   hw/usb/hcd-xhci.c  | 60 ++
> >   hw/usb/hcd-xhci.h  |  1 +
> >   include/hw/virtio/virtio-gpu.h |  1 +
> >   5 files changed, 106 insertions(+), 1 deletion(-)
> > 
> 



Re: [PATCH 1/2] net: forbid the reentrant RX

2020-09-02 Thread Alexander Bulekov
On 200903 1156, Jason Wang wrote:
> 
> On 2020/9/2 下午11:56, Alexander Bulekov wrote:
> > On 200728 1200, Jason Wang wrote:
> > > On 2020/7/22 下午4:57, Jason Wang wrote:
> > > > The memory API allows DMA into NIC's MMIO area. This means the NIC's
> > > > RX routine must be reentrant. Instead of auditing all the NIC, we can
> > > > simply detect the reentrancy and return early. The queue->delivering
> > > > is set and cleared by qemu_net_queue_deliver() for other queue helpers
> > > > to know whether the delivering in on going (NIC's receive is being
> > > > called). We can check it and return early in qemu_net_queue_flush() to
> > > > forbid reentrant RX.
> > > > 
> > > > Signed-off-by: Jason Wang 
> > > > ---
> > > >net/queue.c | 3 +++
> > > >1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/net/queue.c b/net/queue.c
> > > > index 0164727e39..19e32c80fd 100644
> > > > --- a/net/queue.c
> > > > +++ b/net/queue.c
> > > > @@ -250,6 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, 
> > > > NetClientState *from)
> > > >bool qemu_net_queue_flush(NetQueue *queue)
> > > >{
> > > > +if (queue->delivering)
> > > > +return false;
> > > > +
> > > >while (!QTAILQ_EMPTY(>packets)) {
> > > >NetPacket *packet;
> > > >int ret;
> > > 
> > > Queued for rc2.
> > > 
> > > Thanks
> > > 
> > Hi Jason,
> > I don't think this ever made it in. Are there any remaining problems?
> > Thanks
> > -Alex
> 
> 
> Hi Alex:
> 
> It should have been merged:
> 
> https://git.qemu.org/?p=qemu.git;a=commit;h=22dc8663d9fc7baa22100544c600b6285a63c7a3
> 
> Thanks
> 

Ah. I missed only 1/2 was queued. I guess the e1000 patch didn't make
the cut..
Thanks
-Alex

> 
> > 
> 



Re: [PATCH 1/2] net: forbid the reentrant RX

2020-09-02 Thread Jason Wang



On 2020/9/2 下午11:56, Alexander Bulekov wrote:

On 200728 1200, Jason Wang wrote:

On 2020/7/22 下午4:57, Jason Wang wrote:

The memory API allows DMA into NIC's MMIO area. This means the NIC's
RX routine must be reentrant. Instead of auditing all the NIC, we can
simply detect the reentrancy and return early. The queue->delivering
is set and cleared by qemu_net_queue_deliver() for other queue helpers
to know whether the delivering in on going (NIC's receive is being
called). We can check it and return early in qemu_net_queue_flush() to
forbid reentrant RX.

Signed-off-by: Jason Wang 
---
   net/queue.c | 3 +++
   1 file changed, 3 insertions(+)

diff --git a/net/queue.c b/net/queue.c
index 0164727e39..19e32c80fd 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -250,6 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState 
*from)
   bool qemu_net_queue_flush(NetQueue *queue)
   {
+if (queue->delivering)
+return false;
+
   while (!QTAILQ_EMPTY(>packets)) {
   NetPacket *packet;
   int ret;


Queued for rc2.

Thanks


Hi Jason,
I don't think this ever made it in. Are there any remaining problems?
Thanks
-Alex



Hi Alex:

It should have been merged:

https://git.qemu.org/?p=qemu.git;a=commit;h=22dc8663d9fc7baa22100544c600b6285a63c7a3

Thanks









Re: [RFC 0/3] try to solve the DMA to MMIO issue

2020-09-02 Thread Jason Wang



On 2020/9/3 上午12:22, Li Qiang wrote:

The qemu device fuzzer has found several DMA to MMIO issue.
These issues is caused by the guest driver programs the DMA
address, then in the device MMIO handler it trigger the DMA
and as the DMA address is MMIO it will trigger another dispatch
and reenter the MMIO handler again. However most of the device
is not reentrant.

DMA to MMIO will cause issues depend by the device emulator,
mostly it will crash the qemu. Following is three classic
DMA to MMIO issue.

e1000e: https://bugs.launchpad.net/qemu/+bug/1886362
xhci: https://bugs.launchpad.net/qemu/+bug/1891354
virtio-gpu: https://bugs.launchpad.net/qemu/+bug/1888606

The DMA to MMIO issue I think can be classified as following:
1. DMA to the device itself
2. device A DMA to device B and to device C
3. device A DMA to device B and to device A

The first case of course should not be allowed.
The second case I think it ok as the device IO handler has no
assumption about the IO data came from no matter it come from
device or other device. This is for P2P DMA.
The third case I think it also should not be allowed.

So our issue has been reduced by one case: not allowed the
device's IO handler reenter.

Paolo suggested that we can refactor the device emulation with
BH. However it is a lot of work.
I have thought several propose to address this, also discuss
this with Jason Wang in private email.

I have can solve this issue in core framework or in specific device.
After try several methods I choose address it in per-device for
following reason:
1. If we address it in core framwork we have to recored and check the
device or MR info in MR dispatch write function. Unfortunally we have
no these info in core framework.
2. The performance will also be decrease largely
3. Only the device itself know its IO



I think we still need to seek a way to address this issue completely.

How about adding a flag in MemoryRegionOps and detect the reentrancy 
through that flag?


Thanks




The (most of the) device emulation is protected by BQL one time only
a device emulation code can be run. We can add a flag to indicate the
IO is running. The first two patches does this. For simplicity at the
RFC stage I just set it while enter the IO callback and clear it exit
the IO callback. It should be check/set/clean according the per-device's
IO emulation.
The second issue which itself suffers a race condition so I uses a
atomic.




Li Qiang (3):
   e1000e: make the IO handler reentrant
   xhci: make the IO handler reentrant
   virtio-gpu: make the IO handler reentrant

  hw/display/virtio-gpu.c| 10 ++
  hw/net/e1000e.c| 35 +++-
  hw/usb/hcd-xhci.c  | 60 ++
  hw/usb/hcd-xhci.h  |  1 +
  include/hw/virtio/virtio-gpu.h |  1 +
  5 files changed, 106 insertions(+), 1 deletion(-)






Re: [PULL v2 00/76] target/microblaze improvements

2020-09-02 Thread Richard Henderson
On 9/2/20 4:11 PM, Richard Henderson wrote:
> On 9/2/20 12:09 PM, Thomas Huth wrote:
>> On 01/09/2020 17.20, Richard Henderson wrote:
>>> Version 2.  Serves me right for not testing 32-bit host
>>> when I knew there was a patch that mattered.
>>
>>  Hi Richard,
>>
>> I'm afraid, but I think this PR broke the
>> tests/acceptance/replay_kernel.py:ReplayKernel.test_microblaze_s3adsp1800 
>> acceptance
>> test:
>>
>> https://gitlab.com/qemu-project/qemu/-/jobs/716158589#L176
>>
>> Could you please have a look?
> 
> That's odd.
> 
> Doesn't replay rely on migration (or at least VMStateDescription) to do its
> job?  Microblaze doesn't implement that, so how could this have worked before?
> 
> I admit that I don't often run check-acceptance, because I rarely see a clean
> bill of health, even for stuff I'm not working on.
> 
> Looking into it...

Ah, in this case it's all about the icount setting.

So the log recorded by replay=record is indeed useless for input to
replay=replay, but not relevant.


r~



Re: [PATCH v2 0/7] pseries NUMA distance rework

2020-09-02 Thread David Gibson
On Tue, Sep 01, 2020 at 09:56:38AM -0300, Daniel Henrique Barboza wrote:
> Hi,
> 
> Following the reviews of the first version [1], specially this
> reply from David [2], I decided to take a step back and refactor
> all the code in hw/ppc/spapr* that operates with ibm,associativity,
> ibm,associativity-reference-points and ibm,max-associativity-domains.
> 
> A new file named 'spapr_numa.c' was created to gather all the
> associativity related code into helpers that write NUMA/associativity
> related info to the FDT. These helpers are then used in other
> spapr_* files. This allows us to change NUMA related code in a
> single location, instead of searching every file to see where is
> associativity being written and how, and all the soon to get
> more complex logic can be contained in spapr_numa.c. I consider
> the end result to be better than what I ended up doing in v1.
> 
> Unlike v1, there is no NUMA distance change being done in this series.
> Later on, the hub of the new NUMA distance calculation will be
> spapr_numa_associativity_init(), where we'll take into consideration
> user input from numa_states, handle sizes to what the PAPR kernel
> understands and establish assoaciativity domains between the NUMA
> nodes.

Patches 1..4 applied to ppc-for-5.2.  Patch 5 has some nits I've
commented on.

> 
> 
> Changes from v1:
> - all the patches that did guest visible changes were removed. They
> will be re-submitted in a follow-up series after this one.
> - patch 02 from v1 will be reworked and reposted in the follow-up
> series as well.
> - version 1 link:
> https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg03169.html
> 
> 
> 
> These patches were rebased using David's ppc-for-5.2 tree. Github
> repo with the patches applied:
> 
> https://github.com/danielhb/qemu/tree/spapr_numa_v2
> 
> 
> [1] https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg03169.html
> [2] https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg04661.html
>  
> Daniel Henrique Barboza (7):
>   ppc: introducing spapr_numa.c NUMA code helper
>   ppc/spapr_nvdimm: turn spapr_dt_nvdimm() static
>   spapr: introduce SpaprMachineClass::numa_assoc_array
>   spapr, spapr_numa: handle vcpu ibm,associativity
>   spapr, spapr_numa: move lookup-arrays handling to spapr_numa.c
>   spapr_numa: move NVLink2 associativity handling to spapr_numa.c
>   spapr_hcall: h_home_node_associativity now reads numa_assoc_array
> 
>  hw/ppc/meson.build|   3 +-
>  hw/ppc/spapr.c|  91 +++---
>  hw/ppc/spapr_hcall.c  |  16 +++-
>  hw/ppc/spapr_numa.c   | 172 ++
>  hw/ppc/spapr_nvdimm.c |  37 
>  hw/ppc/spapr_pci.c|   9 +-
>  hw/ppc/spapr_pci_nvlink2.c|  19 +---
>  include/hw/ppc/spapr.h|  13 ++-
>  include/hw/ppc/spapr_numa.h   |  32 +++
>  include/hw/ppc/spapr_nvdimm.h |   3 +-
>  10 files changed, 268 insertions(+), 127 deletions(-)
>  create mode 100644 hw/ppc/spapr_numa.c
>  create mode 100644 include/hw/ppc/spapr_numa.h
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [PATCH v2 6/7] spapr_numa: move NVLink2 associativity handling to spapr_numa.c

2020-09-02 Thread David Gibson
On Tue, Sep 01, 2020 at 09:56:44AM -0300, Daniel Henrique Barboza wrote:
> This patch adds a new spapr_numa_write_assoc_nvlink2() helper
> to handle the ibm,associativity for NVLink2 GPUs.
> 
> Signed-off-by: Daniel Henrique Barboza 

Reviewed-by: David Gibson 

It might be nice to "precompute" the assoc arrays for the gpus as you
now do for the regular numa nodes.  That can be a later revision, though.

> ---
>  hw/ppc/spapr_numa.c | 23 +++
>  hw/ppc/spapr_pci_nvlink2.c  | 19 ++-
>  include/hw/ppc/spapr_numa.h |  3 +++
>  3 files changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
> index 9eb4bdbe80..785cc24624 100644
> --- a/hw/ppc/spapr_numa.c
> +++ b/hw/ppc/spapr_numa.c
> @@ -15,6 +15,8 @@
>  #include "hw/ppc/spapr_numa.h"
>  #include "hw/ppc/fdt.h"
>  
> +/* Moved from hw/ppc/spapr_pci_nvlink2.c */
> +#define SPAPR_GPU_NUMA_ID   (cpu_to_be32(1))
>  
>  void spapr_numa_associativity_init(MachineState *machine)
>  {
> @@ -114,6 +116,27 @@ int 
> spapr_numa_write_assoc_lookup_arrays(SpaprMachineState *spapr, void *fdt,
>  return ret;
>  }
>  
> +void spapr_numa_write_assoc_nvlink2(void *fdt, int offset, int numa_id,
> +SpaprPhbState *sphb)
> +{
> +uint32_t associativity[NUMA_ASSOC_SIZE];
> +int i;
> +
> +associativity[0] = cpu_to_be32(MAX_DISTANCE_REF_POINTS);
> +for (i = 1; i < NUMA_ASSOC_SIZE; i++) {
> +associativity[i] = cpu_to_be32(numa_id);
> +};
> +
> +if (sphb->pre_5_1_assoc) {
> +associativity[1] = SPAPR_GPU_NUMA_ID;
> +associativity[2] = SPAPR_GPU_NUMA_ID;
> +associativity[3] = SPAPR_GPU_NUMA_ID;
> +}
> +
> +_FDT((fdt_setprop(fdt, offset, "ibm,associativity", associativity,
> +  sizeof(associativity;
> +}
> +
>  /*
>   * Helper that writes ibm,associativity-reference-points and
>   * max-associativity-domains in the RTAS pointed by @rtas
> diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
> index 76ae77ebc8..662a0af990 100644
> --- a/hw/ppc/spapr_pci_nvlink2.c
> +++ b/hw/ppc/spapr_pci_nvlink2.c
> @@ -29,6 +29,7 @@
>  #include "qemu/error-report.h"
>  #include "hw/ppc/fdt.h"
>  #include "hw/pci/pci_bridge.h"
> +#include "hw/ppc/spapr_numa.h"
>  
>  #define PHANDLE_PCIDEV(phb, pdev)(0x1200 | \
>   (((phb)->index) << 16) | 
> ((pdev)->devfn))
> @@ -37,8 +38,6 @@
>  #define PHANDLE_NVLINK(phb, gn, nn)  (0x0013 | (((phb)->index) << 8) | \
>   ((gn) << 4) | (nn))
>  
> -#define SPAPR_GPU_NUMA_ID   (cpu_to_be32(1))
> -
>  typedef struct SpaprPhbPciNvGpuSlot {
>  uint64_t tgt;
>  uint64_t gpa;
> @@ -360,13 +359,6 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState 
> *sphb, void *fdt)
>  Object *nv_mrobj = object_property_get_link(OBJECT(nvslot->gpdev),
>  "nvlink2-mr[0]",
>  _abort);
> -uint32_t associativity[] = {
> -cpu_to_be32(0x4),
> -cpu_to_be32(nvslot->numa_id),
> -cpu_to_be32(nvslot->numa_id),
> -cpu_to_be32(nvslot->numa_id),
> -cpu_to_be32(nvslot->numa_id)
> -};
>  uint64_t size = object_property_get_uint(nv_mrobj, "size", NULL);
>  uint64_t mem_reg[2] = { cpu_to_be64(nvslot->gpa), cpu_to_be64(size) 
> };
>  char *mem_name = g_strdup_printf("memory@%"PRIx64, nvslot->gpa);
> @@ -376,14 +368,7 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState 
> *sphb, void *fdt)
>  _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
>  _FDT((fdt_setprop(fdt, off, "reg", mem_reg, sizeof(mem_reg;
>  
> -if (sphb->pre_5_1_assoc) {
> -associativity[1] = SPAPR_GPU_NUMA_ID;
> -associativity[2] = SPAPR_GPU_NUMA_ID;
> -associativity[3] = SPAPR_GPU_NUMA_ID;
> -}
> -
> -_FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity,
> -  sizeof(associativity;
> +spapr_numa_write_assoc_nvlink2(fdt, off, nvslot->numa_id, sphb);
>  
>  _FDT((fdt_setprop_string(fdt, off, "compatible",
>   "ibm,coherent-device-memory")));
> diff --git a/include/hw/ppc/spapr_numa.h b/include/hw/ppc/spapr_numa.h
> index f6127501a6..b6e0721b07 100644
> --- a/include/hw/ppc/spapr_numa.h
> +++ b/include/hw/ppc/spapr_numa.h
> @@ -15,6 +15,7 @@
>  
>  #include "hw/boards.h"
>  #include "hw/ppc/spapr.h"
> +#include "hw/pci-host/spapr.h"
>  
>  void spapr_numa_associativity_init(MachineState *machine);
>  void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rtas);
> @@ -24,6 +25,8 @@ int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, void 
> *fdt,
>  int offset, PowerPCCPU 

Re: [PATCH v2 3/7] spapr: introduce SpaprMachineClass::numa_assoc_array

2020-09-02 Thread David Gibson
On Tue, Sep 01, 2020 at 09:56:41AM -0300, Daniel Henrique Barboza wrote:
> The next step to centralize all NUMA/associativity handling in
> the spapr machine is to create a 'one stop place' for all
> things ibm,associativity.
> 
> This patch introduces numa_assoc_array, a 2 dimensional array
> that will store all ibm,associativity arrays of all NUMA nodes.
> This array is initialized in a new spapr_numa_associativity_init()
> function, called in spapr_machine_init(). It is being initialized
> with the same values used in other ibm,associativity properties
> around spapr files (i.e. all zeros, last value is node_id).
> The idea is to remove all hardcoded definitions and FDT writes
> of ibm,associativity arrays, doing instead a call to the new
> helper spapr_numa_write_associativity_dt() helper, that will
> be able to write the DT with the correct values.
> 
> We'll start small, handling the trivial cases first. The
> remaining instances of ibm,associativity will be handled
> next.
> 
> Signed-off-by: Daniel Henrique Barboza 

The idea is great, but there's one small but significant problem here:

> +void spapr_numa_associativity_init(MachineState *machine)
> +{
> +SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
> +int nb_numa_nodes = machine->numa_state->num_nodes;
> +int i;
> +
> +/*
> + * For all associativity arrays: first position is the size,
> + * position MAX_DISTANCE_REF_POINTS is always the numa_id,
> + * represented by the index 'i'.
> + *
> + * This will break on sparse NUMA setups, when/if QEMU starts
> + * to support it, because there will be no more guarantee that
> + * 'i' will be a valid node_id set by the user.
> + */
> +for (i = 0; i < nb_numa_nodes; i++) {
> +smc->numa_assoc_array[i][0] = cpu_to_be32(MAX_DISTANCE_REF_POINTS);
> +smc->numa_assoc_array[i][MAX_DISTANCE_REF_POINTS] = cpu_to_be32(i);

This initialization is called on a machine *instance*, which means it
should treat the machine class as read-only.  i.e. the
numa_assoc_array should be in the SpaprMachineState, rather than the
class.

I mean, we'd get away with it in practice, since there's only ever
likely to be a single machine instance, but still we should correct
this.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [PATCH v2 7/7] spapr_hcall: h_home_node_associativity now reads numa_assoc_array

2020-09-02 Thread David Gibson
On Tue, Sep 01, 2020 at 09:56:45AM -0300, Daniel Henrique Barboza wrote:
> home_node_associativity reply now uses the associativity
> values for tcpu->node_id provided by numa_assoc_array.
> 
> This will avoid further changes in this code when numa_assoc_array
> changes values, but it won't be enough to prevent further changes
> if (falar aqui q se mudar o tamanho do array tem q mexer nessa
> funcao tambem, falar q a macro associativity() deixa a automacao
> de tudo mto unreadable)

Uh.. I'm guessing that was a note to yourself you intended to
translate before publishing?

> 
> Signed-off-by: Daniel Henrique Barboza 
> ---
>  hw/ppc/spapr_hcall.c | 16 ++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index c1d01228c6..2ec30efdcb 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -1878,9 +1878,13 @@ static target_ulong 
> h_home_node_associativity(PowerPCCPU *cpu,
>target_ulong opcode,
>target_ulong *args)

You could move this function to spapr_numa.c as well (the name's a bit
misleading, but spapr_hcall.c isn't really intended to hold *all*
hcall implementations, just the ones that don't have somewhere better
to live).

>  {
> +SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
>  target_ulong flags = args[0];
>  target_ulong procno = args[1];
>  PowerPCCPU *tcpu;
> +uint32_t assoc_domain1;
> +uint32_t assoc_domain2;
> +uint32_t assoc_domain3;
>  int idx;
>  
>  /* only support procno from H_REGISTER_VPA */
> @@ -1893,13 +1897,21 @@ static target_ulong 
> h_home_node_associativity(PowerPCCPU *cpu,
>  return H_P2;
>  }
>  
> +/*
> + * Index 0 is the ibm,associativity size of the node,
> + * which isn't relevant here.
> + */
> +assoc_domain1 = smc->numa_assoc_array[tcpu->node_id][1];
> +assoc_domain2 = smc->numa_assoc_array[tcpu->node_id][2];
> +assoc_domain3 = smc->numa_assoc_array[tcpu->node_id][3];

Using all these temporaries is a little ugly.  Maybe do something like:
uint32_t *assoc = smc->numa_assoc_array[tcpu->node_id];

Then just use assoc[1], assoc[2] etc. below.

> +
>  /* sequence is the same as in the "ibm,associativity" property */
>  
>  idx = 0;
>  #define ASSOCIATIVITY(a, b) (((uint64_t)(a) << 32) | \
>   ((uint64_t)(b) & 0x))
> -args[idx++] = ASSOCIATIVITY(0, 0);
> -args[idx++] = ASSOCIATIVITY(0, tcpu->node_id);
> +args[idx++] = ASSOCIATIVITY(assoc_domain1, assoc_domain2);
> +args[idx++] = ASSOCIATIVITY(assoc_domain3, tcpu->node_id);
>  args[idx++] = ASSOCIATIVITY(procno, -1);
>  for ( ; idx < 6; idx++) {
>  args[idx] = -1;

Better yet would be to make this handle an arbitrary length of assoc
array, further isolating this from the specifics of how we construct
the arrays.  Ideally, you'd call a common path with
spapr_numa_fixup_cpu_dt() to get the assoc array for a cpu, then here
just translate it into the in-register format the hcall expects.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [PATCH v2 0/7] pseries NUMA distance rework

2020-09-02 Thread David Gibson
On Thu, Sep 03, 2020 at 11:35:39AM +1000, David Gibson wrote:
> On Tue, Sep 01, 2020 at 09:56:38AM -0300, Daniel Henrique Barboza wrote:
> > Hi,
> > 
> > Following the reviews of the first version [1], specially this
> > reply from David [2], I decided to take a step back and refactor
> > all the code in hw/ppc/spapr* that operates with ibm,associativity,
> > ibm,associativity-reference-points and ibm,max-associativity-domains.
> > 
> > A new file named 'spapr_numa.c' was created to gather all the
> > associativity related code into helpers that write NUMA/associativity
> > related info to the FDT. These helpers are then used in other
> > spapr_* files. This allows us to change NUMA related code in a
> > single location, instead of searching every file to see where is
> > associativity being written and how, and all the soon to get
> > more complex logic can be contained in spapr_numa.c. I consider
> > the end result to be better than what I ended up doing in v1.
> > 
> > Unlike v1, there is no NUMA distance change being done in this series.
> > Later on, the hub of the new NUMA distance calculation will be
> > spapr_numa_associativity_init(), where we'll take into consideration
> > user input from numa_states, handle sizes to what the PAPR kernel
> > understands and establish assoaciativity domains between the NUMA
> > nodes.
> 
> Patches 1..4 applied to ppc-for-5.2.  Patch 5 has some nits I've
> commented on.

Ah, sorry, I realised I missed something.  Patches 1..2 are still
applied, but patch 3 has a nit large enough to call for a respin.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [PATCH v2 5/7] spapr, spapr_numa: move lookup-arrays handling to spapr_numa.c

2020-09-02 Thread David Gibson
On Tue, Sep 01, 2020 at 09:56:43AM -0300, Daniel Henrique Barboza wrote:
> In a similar fashion as the previous patch, let's move the
> handling of ibm,associativity-lookup-arrays from spapr.c to
> spapr_numa.c. A spapr_numa_write_assoc_lookup_arrays() helper was
> created, and spapr_dt_dynamic_reconfiguration_memory() can now
> use it to advertise the lookup-arrays.
> 
> Signed-off-by: Daniel Henrique Barboza 
> ---
>  hw/ppc/spapr.c  | 25 ++--
>  hw/ppc/spapr_numa.c | 39 +
>  include/hw/ppc/spapr_numa.h |  2 ++
>  3 files changed, 43 insertions(+), 23 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 172f965fe0..65d2ccd578 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -535,13 +535,10 @@ static int 
> spapr_dt_dynamic_reconfiguration_memory(SpaprMachineState *spapr,
> void *fdt)
>  {
>  MachineState *machine = MACHINE(spapr);
> -int nb_numa_nodes = machine->numa_state->num_nodes;
> -int ret, i, offset;
> +int ret, offset;
>  uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
>  uint32_t prop_lmb_size[] = {cpu_to_be32(lmb_size >> 32),
>  cpu_to_be32(lmb_size & 0x)};
> -uint32_t *int_buf, *cur_index, buf_len;
> -int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1;
>  MemoryDeviceInfoList *dimms = NULL;
>  
>  /*
> @@ -582,25 +579,7 @@ static int 
> spapr_dt_dynamic_reconfiguration_memory(SpaprMachineState *spapr,
>  return ret;
>  }
>  
> -/* ibm,associativity-lookup-arrays */
> -buf_len = (nr_nodes * 4 + 2) * sizeof(uint32_t);
> -cur_index = int_buf = g_malloc0(buf_len);
> -int_buf[0] = cpu_to_be32(nr_nodes);
> -int_buf[1] = cpu_to_be32(4); /* Number of entries per associativity list 
> */
> -cur_index += 2;
> -for (i = 0; i < nr_nodes; i++) {
> -uint32_t associativity[] = {
> -cpu_to_be32(0x0),
> -cpu_to_be32(0x0),
> -cpu_to_be32(0x0),
> -cpu_to_be32(i)
> -};
> -memcpy(cur_index, associativity, sizeof(associativity));
> -cur_index += 4;
> -}
> -ret = fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", 
> int_buf,
> -(cur_index - int_buf) * sizeof(uint32_t));
> -g_free(int_buf);
> +ret = spapr_numa_write_assoc_lookup_arrays(spapr, fdt, offset);
>  
>  return ret;
>  }
> diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
> index b8882d209e..9eb4bdbe80 100644
> --- a/hw/ppc/spapr_numa.c
> +++ b/hw/ppc/spapr_numa.c
> @@ -75,6 +75,45 @@ int spapr_numa_fixup_cpu_dt(SpaprMachineState *spapr, void 
> *fdt,
> vcpu_assoc, sizeof(vcpu_assoc));
>  }
>  
> +
> +int spapr_numa_write_assoc_lookup_arrays(SpaprMachineState *spapr, void *fdt,
> + int offset)
> +{
> +MachineState *machine = MACHINE(spapr);
> +SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
> +int nb_numa_nodes = machine->numa_state->num_nodes;
> +int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1;
> +uint32_t *int_buf, *cur_index, buf_len;
> +int ret, i, j;
> +
> +/* ibm,associativity-lookup-arrays */
> +buf_len = (nr_nodes * MAX_DISTANCE_REF_POINTS + 2) * sizeof(uint32_t);
> +cur_index = int_buf = g_malloc0(buf_len);
> +int_buf[0] = cpu_to_be32(nr_nodes);
> + /* Number of entries per associativity list */
> +int_buf[1] = cpu_to_be32(MAX_DISTANCE_REF_POINTS);
> +cur_index += 2;
> +for (i = 0; i < nr_nodes; i++) {
> +/*
> + * For the lookup-array we use the ibm,associativity array,
> + * from numa_assoc_array. without the first element (size).
> + */
> +uint32_t associativity[MAX_DISTANCE_REF_POINTS];
> +
> +for (j = 0; j < MAX_DISTANCE_REF_POINTS; j++) {
> +associativity[j] = smc->numa_assoc_array[i][j + 1];
> +}
> +
> +memcpy(cur_index, associativity, sizeof(associativity));

AFAICT, you could just use a single memcpy() to copy from the
numa_assoc_array() into the property here, rather than using a loop
and temporary array.

> +cur_index += 4;

Shouldn't this be  += MAX_DISTANCE_REF_POINTS?

> +}
> +ret = fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", 
> int_buf,
> +  (cur_index - int_buf) * sizeof(uint32_t));
> +g_free(int_buf);
> +
> +return ret;
> +}
> +
>  /*
>   * Helper that writes ibm,associativity-reference-points and
>   * max-associativity-domains in the RTAS pointed by @rtas
> diff --git a/include/hw/ppc/spapr_numa.h b/include/hw/ppc/spapr_numa.h
> index f92fb4f28a..f6127501a6 100644
> --- a/include/hw/ppc/spapr_numa.h
> +++ b/include/hw/ppc/spapr_numa.h
> @@ -22,6 +22,8 @@ void spapr_numa_write_associativity_dt(SpaprMachineState 
> *spapr, void *fdt,
> int 

Re: [PATCH V2 for-5.2] hw/null-machine: Add the kvm_type() hook for MIPS

2020-09-02 Thread Huacai Chen
Hi, Philippe,

On Wed, Sep 2, 2020 at 9:55 PM Philippe Mathieu-Daudé  wrote:
>
> Hi Huacai,
>
> On 8/24/20 10:11 AM, Huacai Chen wrote:
> > MIPS has two types of KVM: TE & VZ, and TE is the default type. Now,
> > libvirt uses a null-machine to detect the kvm capability. In the MIPS
> > case, it will return "KVM not supported" on a VZ platform by default.
> > So, add the kvm_type() hook to the null-machine.
> >
> > This seems not a very good solution, but I cannot do it better now.
> >
> > Reviewed-by: Aleksandar Markovic 
> > Signed-off-by: Huacai Chen 
> > Co-developed-by: Jiaxun Yang 
> > ---
> >  hw/core/meson.build| 2 +-
> >  hw/core/null-machine.c | 6 ++
> >  2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/core/meson.build b/hw/core/meson.build
> > index fc91f98..b6591b9 100644
> > --- a/hw/core/meson.build
> > +++ b/hw/core/meson.build
> > @@ -35,7 +35,6 @@ softmmu_ss.add(files(
> >'machine-hmp-cmds.c',
> >'machine.c',
> >'nmi.c',
> > -  'null-machine.c',
> >'qdev-fw.c',
> >'qdev-properties-system.c',
> >'sysbus.c',
> > @@ -45,5 +44,6 @@ softmmu_ss.add(files(
> >
> >  specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: files(
> >'machine-qmp-cmds.c',
> > +  'null-machine.c',
> >'numa.c',
> >  ))
> > diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
> > index 7e69352..4b4ab76 100644
> > --- a/hw/core/null-machine.c
> > +++ b/hw/core/null-machine.c
> > @@ -17,6 +17,9 @@
> >  #include "sysemu/sysemu.h"
> >  #include "exec/address-spaces.h"
> >  #include "hw/core/cpu.h"
> > +#ifdef TARGET_MIPS
> > +#include "kvm_mips.h"
> > +#endif
> >
> >  static void machine_none_init(MachineState *mch)
> >  {
> > @@ -55,6 +58,9 @@ static void machine_none_machine_init(MachineClass *mc)
> >  mc->no_floppy = 1;
> >  mc->no_cdrom = 1;
> >  mc->no_sdcard = 1;
> > +#ifdef TARGET_MIPS
> > +mc->kvm_type = mips_kvm_type;
> > +#endif
>
> I'm a bit confused here, you are taking the same path from your v4...
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg712550.html
>
> Did you rebase the correct version?
The old patch has split to two parts, the first part is used by MIPS
machine and already merged. This is the second part used by the
null-machine (and libvirt use null-machine to detect kvm
capabilities).

Huacai
>
> >  }
> >
> >  DEFINE_MACHINE("none", machine_none_machine_init)
> >



Re: [RFC v8 5/5] memory: Skip bad range assertion if notifier is DEVIOTLB type

2020-09-02 Thread David Gibson
On Wed, Sep 02, 2020 at 04:24:50PM +0200, Auger Eric wrote:
> Hi Eugenio,
> 
> On 9/1/20 4:26 PM, Eugenio Pérez wrote:
> > Signed-off-by: Eugenio Pérez 
> Please could you explain in the commit message why you need to remove
> the assert()? I know you described the assert() in the cover letter but
> the commit msg is the one that remains.

Right... neither in the cover letter nor the individual patches,
AFAICT, does anything actually explain why that assert() could be
hit.  Nor does it connect the dots from an assert() hitting to adding
infrastructure for a new event type.

> > ---
> >  softmmu/memory.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/softmmu/memory.c b/softmmu/memory.c
> > index 09b3443eac..3ee99b4dc0 100644
> > --- a/softmmu/memory.c
> > +++ b/softmmu/memory.c
> > @@ -1895,6 +1895,7 @@ void memory_region_notify_iommu_one(IOMMUNotifier 
> > *notifier,
> >  {
> >  IOMMUTLBEntry *entry = >entry;
> >  hwaddr entry_end = entry->iova + entry->addr_mask;
> > +IOMMUTLBEntry tmp = *entry;
> >  
> >  /*
> >   * Skip the notification if the notification does not overlap
> > @@ -1904,10 +1905,18 @@ void memory_region_notify_iommu_one(IOMMUNotifier 
> > *notifier,
> >  return;
> >  }
> >  
> > -assert(entry->iova >= notifier->start && entry_end <= notifier->end);
> > +if (notifier->notifier_flags & IOMMU_NOTIFIER_DEVIOTLB) {
> > +/* Crop (iova, addr_mask) to range */
> > +tmp.iova = MAX(tmp.iova, notifier->start);
> > +tmp.addr_mask = MIN(entry_end, notifier->end) - tmp.iova;
> > +/* Confirm no underflow */
> > +assert(MIN(entry_end, notifier->end) >= tmp.iova);
> > +} else {
> > +assert(entry->iova >= notifier->start && entry_end <= 
> > notifier->end);
> > +}
> >  
> >  if (event->type & notifier->notifier_flags) {
> > -notifier->notify(notifier, entry);
> > +notifier->notify(notifier, );
> >  }
> >  }
> >  
> > 
> Thanks
> 
> Eric
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


RE: [PATCH 40/63] filter-rewriter: Rename FILTER_COLO_REWRITER to FILTER_REWRITER

2020-09-02 Thread Zhang, Chen



> -Original Message-
> From: Eduardo Habkost 
> Sent: Thursday, September 3, 2020 6:43 AM
> To: qemu-devel@nongnu.org
> Cc: berra...@redhat.com; Zhang, Chen ; Li Zhijian
> ; Jason Wang 
> Subject: [PATCH 40/63] filter-rewriter: Rename FILTER_COLO_REWRITER to
> FILTER_REWRITER
> 
> Make the type checking macro name consistent with the TYPE_* constant.
> 
> Signed-off-by: Eduardo Habkost 

Reviewed-by: Zhang Chen 

Thanks
Zhang Chen

> ---
> Cc: Zhang Chen 
> Cc: Li Zhijian 
> Cc: Jason Wang 
> Cc: qemu-devel@nongnu.org
> ---
>  net/filter-rewriter.c | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index
> 113e293207..44f6021dd8 100644
> --- a/net/filter-rewriter.c
> +++ b/net/filter-rewriter.c
> @@ -25,7 +25,7 @@
> 
>  #define TYPE_FILTER_REWRITER "filter-rewriter"
>  typedef struct RewriterState RewriterState; -
> DECLARE_INSTANCE_CHECKER(RewriterState, FILTER_COLO_REWRITER,
> +DECLARE_INSTANCE_CHECKER(RewriterState, FILTER_REWRITER,
>   TYPE_FILTER_REWRITER)
> 
>  #define FAILOVER_MODE_ON  true
> @@ -47,7 +47,7 @@ static void filter_rewriter_failover_mode(RewriterState
> *s)
> 
>  static void filter_rewriter_flush(NetFilterState *nf)  {
> -RewriterState *s = FILTER_COLO_REWRITER(nf);
> +RewriterState *s = FILTER_REWRITER(nf);
> 
>  if (!qemu_net_queue_flush(s->incoming_queue)) {
>  /* Unable to empty the queue, purge remaining packets */ @@ -252,7
> +252,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
>   int iovcnt,
>   NetPacketSent *sent_cb)  {
> -RewriterState *s = FILTER_COLO_REWRITER(nf);
> +RewriterState *s = FILTER_REWRITER(nf);
>  Connection *conn;
>  ConnectionKey key;
>  Packet *pkt;
> @@ -350,7 +350,7 @@ static gboolean offset_is_nonzero(gpointer key,
> static void colo_rewriter_handle_event(NetFilterState *nf, int event,
> Error **errp)  {
> -RewriterState *rs = FILTER_COLO_REWRITER(nf);
> +RewriterState *rs = FILTER_REWRITER(nf);
> 
>  switch (event) {
>  case COLO_EVENT_CHECKPOINT:
> @@ -370,7 +370,7 @@ static void
> colo_rewriter_handle_event(NetFilterState *nf, int event,
> 
>  static void colo_rewriter_cleanup(NetFilterState *nf)  {
> -RewriterState *s = FILTER_COLO_REWRITER(nf);
> +RewriterState *s = FILTER_REWRITER(nf);
> 
>  /* flush packets */
>  if (s->incoming_queue) {
> @@ -381,7 +381,7 @@ static void colo_rewriter_cleanup(NetFilterState *nf)
> 
>  static void colo_rewriter_setup(NetFilterState *nf, Error **errp)  {
> -RewriterState *s = FILTER_COLO_REWRITER(nf);
> +RewriterState *s = FILTER_REWRITER(nf);
> 
>  s->connection_track_table =
> g_hash_table_new_full(connection_key_hash,
>connection_key_equal, 
> @@ -392,7 +392,7 @@
> static void colo_rewriter_setup(NetFilterState *nf, Error **errp)
> 
>  static bool filter_rewriter_get_vnet_hdr(Object *obj, Error **errp)  {
> -RewriterState *s = FILTER_COLO_REWRITER(obj);
> +RewriterState *s = FILTER_REWRITER(obj);
> 
>  return s->vnet_hdr;
>  }
> @@ -401,14 +401,14 @@ static void filter_rewriter_set_vnet_hdr(Object
> *obj,
>   bool value,
>   Error **errp)  {
> -RewriterState *s = FILTER_COLO_REWRITER(obj);
> +RewriterState *s = FILTER_REWRITER(obj);
> 
>  s->vnet_hdr = value;
>  }
> 
>  static void filter_rewriter_init(Object *obj)  {
> -RewriterState *s = FILTER_COLO_REWRITER(obj);
> +RewriterState *s = FILTER_REWRITER(obj);
> 
>  s->vnet_hdr = false;
>  s->failover_mode = FAILOVER_MODE_OFF;
> --
> 2.26.2




[PULL 8/9] linux-user: Add support for btrfs ioctls used to manage quota

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality for following ioctls:

BTRFS_IOC_QUOTA_CTL - Enabling/Disabling quota support

Enable or disable quota support for a btrfs filesystem. Quota
support is enabled or disabled using the ioctls third argument
which represents a pointer to a following type:

struct btrfs_ioctl_quota_ctl_args {
__u64 cmd;
__u64 status;
};

Before calling this ioctl, the 'cmd' field should be filled
with one of the values 'BTRFS_QUOTA_CTL_ENABLE' (enabling quota)
'BTRFS_QUOTA_CTL_DISABLE' (disabling quota).

BTRFS_IOC_QGROUP_CREATE - Creating/Removing a subvolume quota group

Create or remove a subvolume quota group. The subvolume quota
group is created or removed using the ioctl's third argument which
represents a pointer to a following type:

struct btrfs_ioctl_qgroup_create_args {
__u64 create;
__u64 qgroupid;
};

Before calling this ioctl, the 'create' field should be filled
with the aproppriate value depending on if the user wants to
create or remove a quota group (0 for removing, everything else
for creating). Also, the 'qgroupid' field should be filled with
the value for the quota group id that is to be created.

BTRFS_IOC_QGROUP_ASSIGN - Asigning or removing a quota group as child group

Asign or remove a quota group as child quota group of another
group in the btrfs filesystem. The asignment is done using the
ioctl's third argument which represents a pointert to a following type:

struct btrfs_ioctl_qgroup_assign_args {
__u64 assign;
__u64 src;
__u64 dst;
};

Before calling this ioctl, the 'assign' field should be filled with
the aproppriate value depending on if the user wants to asign or remove
a quota group as a child quota group of another group (0 for removing,
everythin else for asigning). Also, the 'src' and 'dst' fields should
be filled with the aproppriate quota group id values depending on which
quota group needs to asigned or removed as child quota group of another
group ('src' gets asigned or removed as child group of 'dst').

BTRFS_IOC_QGROUP_LIMIT - Limiting the size of a quota group

Limit the size of a quota group. The size of the quota group is limited
with the ioctls third argument which represents a pointer to a following
type:

struct btrfs_ioctl_qgroup_limit_args {
__u64   qgroupid;
struct btrfs_qgroup_limit lim;
};

Before calling this ioctl, the 'qgroup' id field should be filled with
aproppriate value of the quota group id for which the size is to be
limited. The second field is of following type:

struct btrfs_qgroup_limit {
__u64   flags;
__u64   max_rfer;
__u64   max_excl;
__u64   rsv_rfer;
__u64   rsv_excl;
};

The 'max_rfer' field should be filled with the size to which the quota
group should be limited. The 'flags' field can be used for passing
additional options and can have values which can be found on:

https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L67

BTRFS_IOC_QUOTA_RESCAN_STATUS - Checking status of running rescan operation

Check status of a running rescan operation. The status is checked using
the ioctl's third argument which represents a pointer to a following type:

struct btrfs_ioctl_quota_rescan_args {
__u64   flags;
__u64   progress;
__u64   reserved[6];
};

If there is a rescan operation running, 'flags' field is set to 1, and
'progress' field is set to aproppriate value which represents the progress
of the operation.

BTRFS_IOC_QUOTA_RESCAN - Starting a rescan operation

Start ar rescan operation to Trash all quota groups and scan the metadata
again with the current config. Before calling this ioctl,
BTRFS_IOC_QUOTA_RESCAN_STATUS sould be run to check if there is already a
rescan operation runing. After that ioctl call, the received
'struct btrfs_ioctl_quota_rescan_args' should be than passed as this ioctls
third argument.

BTRFS_IOC_QUOTA_RESCAN_WAIT - Waiting for a rescan operation to finish

Wait until a rescan operation is finished (if there is a rescan operation
running). The third ioctls argument is ignored.

Implementation notes:

Almost all of the ioctls in this patch use structure types as third 
arguments.
That is the reason why aproppriate thunk definitions were added in file
'syscall_types.h'.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-8-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h| 27 +++
 linux-user/syscall_defs.h  |  7 +++
 linux-user/syscall_types.h | 29 +
 3 files changed, 63 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h

[PULL 7/9] linux-user: Add support for two btrfs ioctls used for subvolume

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality for following ioctl:

BTRFS_IOC_DEFAULT_SUBVOL - Setting a default subvolume

Set a default subvolume for a btrfs filesystem. The third
ioctl's argument is a '__u64' (unsigned long long) which
represents the id of a subvolume that is to be set as
the default.

BTRFS_IOC_GET_SUBVOL_ROOTREF - Getting tree and directory id of subvolumes

Read tree and directory id of subvolumes from a btrfs
filesystem. The tree and directory id's are returned in the
ioctl's third argument which represents a pointer to a
following type:

struct btrfs_ioctl_get_subvol_rootref_args {
/* in/out, minimum id of rootref's treeid to be searched */
__u64 min_treeid;

/* out */
struct {
__u64 treeid;
__u64 dirid;
} rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];

/* out, number of found items */
__u8 num_items;
__u8 align[7];
 };

 Before calling this ioctl, 'min_treeid' field should be filled
 with value that represent the minimum value for the tree id.

Implementation notes:

Ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF uses the above mentioned structure
type as third argument. That is the reason why a aproppriate thunk
structure definition is added in file 'syscall_types.h'.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-7-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h|  7 +++
 linux-user/syscall_defs.h  |  3 +++
 linux-user/syscall_types.h | 13 +
 3 files changed, 23 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 23807513eed1..dc2f3d2413ed 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -206,6 +206,9 @@
  IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))
 #endif
+#ifdef BTRFS_IOC_DEFAULT_SUBVOL
+ IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG))
+#endif
 #ifdef BTRFS_IOC_SUBVOL_GETFLAGS
  IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))
 #endif
@@ -248,6 +251,10 @@
  IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))
 #endif
+#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF
+ IOCTL(BTRFS_IOC_GET_SUBVOL_ROOTREF, IOC_RW,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args)))
+#endif
 #ifdef BTRFS_IOC_INO_LOOKUP_USER
  IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 4929121956c6..bb60c728d81a 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1014,6 +1014,8 @@ struct target_rtc_pll_info {
 #define TARGET_BTRFS_IOC_SUBVOL_CREATE  TARGET_IOWU(BTRFS_IOCTL_MAGIC, 
14)
 #define TARGET_BTRFS_IOC_SNAP_DESTROY   TARGET_IOWU(BTRFS_IOCTL_MAGIC, 
15)
 #define TARGET_BTRFS_IOC_INO_LOOKUP 
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 18)
+#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAGIC, 
19,\
+   abi_ullong)
 #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGSTARGET_IOR(BTRFS_IOCTL_MAGIC, 
25,\
abi_ullong)
 #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGSTARGET_IOW(BTRFS_IOCTL_MAGIC, 
26,\
@@ -1027,6 +1029,7 @@ struct target_rtc_pll_info {
 #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 
57)
 #define TARGET_BTRFS_IOC_LOGICAL_INO_V2 
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 59)
 #define TARGET_BTRFS_IOC_GET_SUBVOL_INFOTARGET_IORU(BTRFS_IOCTL_MAGIC, 
60)
+#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF 
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 61)
 #define TARGET_BTRFS_IOC_INO_LOOKUP_USER
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 62)
 
 /* usb ioctls */
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index dab2c16bcac7..73e36620cedc 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -435,6 +435,19 @@ STRUCT(btrfs_ioctl_dev_info_args,
MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */
 #endif
 
+#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF
+STRUCT(rootref,
+   TYPE_ULONGLONG, /* treeid */
+   TYPE_ULONGLONG) /* dirid */
+
+STRUCT(btrfs_ioctl_get_subvol_rootref_args,
+   TYPE_ULONGLONG, /* min_treeid */
+   MK_ARRAY(MK_STRUCT(STRUCT_rootref),
+BTRFS_MAX_ROOTREF_BUFFER_NUM), /* rootref */
+   TYPE_CHAR, /* num_items */
+   MK_ARRAY(TYPE_CHAR, 7)) /* align */
+#endif
+
 #ifdef BTRFS_IOC_GET_DEV_STATS
 STRUCT(btrfs_ioctl_get_dev_stats,
TYPE_ULONGLONG, /* devid */
-- 
2.26.2




[PULL 6/9] linux-user: Add support for a group of btrfs inode ioctls

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality of following ioctls:

BTRFS_IOC_INO_LOOKUP - Reading tree root id and path

Read tree root id and path for a given file or directory.
The name and tree root id are returned in an ioctl's third
argument that represents a pointer to a following type:

struct btrfs_ioctl_ino_lookup_args {
__u64 treeid;
__u64 objectid;
char name[BTRFS_INO_LOOKUP_PATH_MAX];
};

Before calling this ioctl, field 'objectid' should be filled
with the object id value for which the tree id and path are
to be read. Value 'BTRFS_FIRST_FREE_OBJECTID' represents the
object id for the first available btrfs object (directory or
file).

BTRFS_IOC_INO_PATHS - Reading paths to all files

Read path to all files with a certain inode number. The paths
are returned in the ioctl's third argument which represents
a pointer to a following type:

struct btrfs_ioctl_ino_path_args {
__u64   inum;   /* in */
__u64   size;   /* in */
__u64   reserved[4];
/* struct btrfs_data_container  *fspath;   out */
__u64   fspath; /* out */
 };

 Before calling this ioctl, the 'inum' and 'size' field should
 be filled with the aproppriate inode number and size of the
 directory where file paths should be looked for. For now, the
 paths are returned in an '__u64' (unsigned long long) value
 'fspath'.

BTRFS_IOC_LOGICAL_INO - Reading inode numbers

 Read inode numbers for files on a certain logical adress. The
 inode numbers are returned in the ioctl's third argument which
 represents a pointer to a following type:

 struct btrfs_ioctl_logical_ino_args {
__u64   logical;/* in */
__u64   size;   /* in */
__u64   reserved[3];/* must be 0 for now */
__u64   flags;  /* in, v2 only */
/* struct btrfs_data_container  *inodes;out   */
__u64   inodes;
 };

 Before calling this ioctl, the 'logical' and 'size' field should
 be filled with the aproppriate logical adress and size of where
 the inode numbers of files should be looked for. For now, the
 inode numbers are returned in an '__u64' (unsigned long long)
 value 'inodes'.

BTRFS_IOC_LOGICAL_INO_V2 - Reading inode numbers

 Same as the above mentioned ioctl except that it allows passing
 a flags 'BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET'.

BTRFS_IOC_INO_LOOKUP_USER - Reading subvolume name and path

 Read name and path of a subvolume. The tree root id and
 path are read in an ioctl's third argument which represents a
 pointer to a following type:

 struct btrfs_ioctl_ino_lookup_user_args {
/* in, inode number containing the subvolume of 'subvolid' */
__u64 dirid;
/* in */
__u64 treeid;
/* out, name of the subvolume of 'treeid' */
char name[BTRFS_VOL_NAME_MAX + 1];
/*
 * out, constructed path from the directory with which the ioctl is
 * called to dirid
 */
char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
 };

 Before calling this ioctl, the 'dirid' and 'treeid' field should
 be filled with aproppriate values which represent the inode number
 of the directory that contains the subvolume and treeid of the
 subvolume.

Implementation notes:

 All of the ioctls in this patch use structure types as third arguments.
 That is the reason why aproppriate thunk definitions were added in file
 'syscall_types.h'.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-6-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h| 20 
 linux-user/syscall_defs.h  |  5 +
 linux-user/syscall_types.h | 32 
 3 files changed, 57 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 11d7361848dd..23807513eed1 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -202,6 +202,10 @@
  IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
 #endif
+#ifdef BTRFS_IOC_INO_LOOKUP
+ IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))
+#endif
 #ifdef BTRFS_IOC_SUBVOL_GETFLAGS
  IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))
 #endif
@@ -212,6 +216,14 @@
  IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args)))
 #endif
+#ifdef BTRFS_IOC_INO_PATHS
+ IOCTL(BTRFS_IOC_INO_PATHS, IOC_RW,
+   

Re: [PATCH v2 3/3] nbd: disable signals and forking on Windows builds

2020-09-02 Thread Eric Blake

On 9/2/20 5:07 PM, 罗勇刚(Yonggang Luo) wrote:

On Tue, Aug 25, 2020 at 6:40 PM Daniel P. Berrangé 
wrote:


Disabling these parts are sufficient to get the qemu-nbd program
compiling in a Windows build.

Signed-off-by: Daniel P. Berrangé 
---
  meson.build | 7 ++-
  qemu-nbd.c  | 5 +
  2 files changed, 7 insertions(+), 5 deletions(-)



+++ b/qemu-nbd.c
@@ -899,6 +899,7 @@ int main(int argc, char **argv)
  #endif

  if ((device && !verbose) || fork_process) {
+#ifndef WIN32
  int stderr_fd[2];
  pid_t pid;
  int ret;
@@ -962,6 +963,10 @@ int main(int argc, char **argv)
   */
  exit(errors);
  }
+#else /* WIN32 */
+error_report("Unable to fork into background on Windows hosts");
+exit(EXIT_FAILURE);
+#endif /* WIN32 */
  }


May us replace fork with alternative such as spawn?


You're certainly welcome to propose a patch along those lines, if 
spawning a task is a common Windows counterpart to the Unix notion of 
forking off a daemon.  But even requiring qemu-nbd to run in the 
foreground is already an improvement over what we had previously, so any 
change to use spawn will be a separate series, and will not hold up this 
one.


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




[PULL 2/9] linux-user: Add support for a group of btrfs ioctls used for subvolumes

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality of following ioctls:

BTRFS_IOC_SUBVOL_CREATE - Creating a btrfs subvolume

Create a btrfs subvolume. The subvolume is created using the ioctl's
third argument which represents a pointer to a following structure
type:

struct btrfs_ioctl_vol_args {
__s64 fd;
char name[BTRFS_PATH_NAME_MAX + 1];
};

Before calling this ioctl, the fields of this structure should be filled
with aproppriate values. The fd field represents the file descriptor
value of the subvolume and the name field represents the subvolume
path.

BTRFS_IOC_SUBVOL_GETFLAGS - Getting subvolume flags

Read the flags of the btrfs subvolume. The flags are read using
the ioctl's third argument that is a pointer of __u64 (unsigned long).
The third argument represents a bit mask that can be composed of following
values:
BTRFS_SUBVOL_RDONLY   (1ULL << 1)
BTRFS_SUBVOL_QGROUP_INHERIT   (1ULL << 2)
BTRFS_DEVICE_SPEC_BY_ID   (1ULL << 3)
BTRFS_SUBVOL_SPEC_BY_ID   (1ULL << 4)

BTRFS_IOC_SUBVOL_SETFLAGS - Setting subvolume flags

Set the flags of the btrfs subvolume. The flags are set using the
ioctl's third argument that is a pointer of __u64 (unsigned long).
The third argument represents a bit mask that can be composed of same
values as in the case of previous ioctl (BTRFS_IOC_SUBVOL_GETFLAGS).

BTRFS_IOC_SUBVOL_GETINFO - Getting subvolume information

Read information about the subvolume. The subvolume information is
returned in the ioctl's third argument which represents a pointer to
a following structure type:

struct btrfs_ioctl_get_subvol_info_args {
/* Id of this subvolume */
__u64 treeid;

/* Name of this subvolume, used to get the real name at mount point */
char name[BTRFS_VOL_NAME_MAX + 1];

/*
 * Id of the subvolume which contains this subvolume.
 * Zero for top-level subvolume or a deleted subvolume.
 */
__u64 parent_id;

/*
 * Inode number of the directory which contains this subvolume.
 * Zero for top-level subvolume or a deleted subvolume
 */
__u64 dirid;

/* Latest transaction id of this subvolume */
__u64 generation;

/* Flags of this subvolume */
__u64 flags;

/* UUID of this subvolume */
__u8 uuid[BTRFS_UUID_SIZE];

/*
 * UUID of the subvolume of which this subvolume is a snapshot.
 * All zero for a non-snapshot subvolume.
 */
__u8 parent_uuid[BTRFS_UUID_SIZE];

/*
 * UUID of the subvolume from which this subvolume was received.
 * All zero for non-received subvolume.
 */
__u8 received_uuid[BTRFS_UUID_SIZE];

/* Transaction id indicating when change/create/send/receive happened */
__u64 ctransid;
__u64 otransid;
__u64 stransid;
__u64 rtransid;
/* Time corresponding to c/o/s/rtransid */
struct btrfs_ioctl_timespec ctime;
struct btrfs_ioctl_timespec otime;
struct btrfs_ioctl_timespec stime;
struct btrfs_ioctl_timespec rtime;

/* Must be zero */
__u64 reserved[8];
 };

 All of the fields of this structure are filled after the ioctl call.

Implementation notes:

Ioctls BTRFS_IOC_SUBVOL_CREATE and BTRFS_IOC_SUBVOL_GETINFO have structure
types as third arguments. That is the reason why a corresponding definition
are added in file 'linux-user/syscall_types.h'.

The line '#include ' is added in file 'linux-user/syscall.c' 
to
recognise preprocessor definitions for these ioctls. Since the file 
"linux/btrfs.h"
was added in the kernel version 3.9, it is enwrapped in an #ifdef statement
with parameter CONFIG_BTRFS which is defined in 'configure' if the
header file is present.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-2-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 configure  |  9 +
 linux-user/ioctls.h| 15 +++
 linux-user/syscall.c   |  3 +++
 linux-user/syscall_defs.h  |  8 
 linux-user/syscall_types.h | 32 
 5 files changed, 67 insertions(+)

diff --git a/configure b/configure
index 8a3acef89d91..277b70f2594e 100755
--- a/configure
+++ b/configure
@@ -4920,6 +4920,12 @@ if check_include sys/kcov.h ; then
 kcov=yes
 fi
 
+# check for btrfs filesystem support (kernel must be 3.9+)
+btrfs=no
+if check_include linux/btrfs.h ; then
+btrfs=yes
+fi
+
 # If we're making warnings fatal, apply this to Sphinx runs as well
 sphinx_werror=""
 if test "$werror" = "yes"; then
@@ -6898,6 +6904,9 @@ fi
 if test "$kcov" = "yes" ; then
   echo "CONFIG_KCOV=y" >> $config_host_mak
 fi
+if test "$btrfs" = "yes" ; then
+  echo "CONFIG_BTRFS=y" >> 

[PULL 3/9] linux-user: Add support for a group of btrfs ioctls used for snapshots

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality for following ioctls:

BTRFS_IOC_SNAP_CREATE - Creating a subvolume snapshot

Create a snapshot of a btrfs subvolume. The snapshot is created using the
ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_args'
(which was mentioned in the previous patch). Before calling this ioctl,
the fields of the structure should be filled with aproppriate values for
the file descriptor and path of the subvolume for which the snapshot is to
be created.

BTRFS_IOC_SNAP_DESTROY - Removing a subvolume snapshot

Delete a snapshot of a btrfs subvolume. The snapshot is deleted using the
ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_args'
(which was mentioned in the previous patch). Before calling this ioctl,
the fields of the structure should be filled with aproppriate values for
the file descriptor and path of the subvolume for which the snapshot is to
be deleted.

Implementation notes:

Since the thunk type 'struct btrfs_ioctl_vol_args' is defined in the
previous patch, the implementation for these ioctls was straightforward.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-3-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h| 8 
 linux-user/syscall_defs.h  | 2 ++
 linux-user/syscall_types.h | 3 ++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index bf89b96d27b0..bddeaca9e7ec 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -174,10 +174,18 @@
  IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
  IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
 
+#ifdef BTRFS_IOC_SNAP_CREATE
+ IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
 #ifdef BTRFS_IOC_SUBVOL_CREATE
  IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
 #endif
+#ifdef BTRFS_IOC_SNAP_DESTROY
+ IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
 #ifdef BTRFS_IOC_SUBVOL_GETFLAGS
  IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))
 #endif
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index cae79f8492e1..1519de7a5565 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1006,7 +1006,9 @@ struct target_rtc_pll_info {
 #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
 
 /* btrfs ioctls */
+#define TARGET_BTRFS_IOC_SNAP_CREATETARGET_IOWU(BTRFS_IOCTL_MAGIC, 
1)
 #define TARGET_BTRFS_IOC_SUBVOL_CREATE  TARGET_IOWU(BTRFS_IOCTL_MAGIC, 
14)
+#define TARGET_BTRFS_IOC_SNAP_DESTROY   TARGET_IOWU(BTRFS_IOCTL_MAGIC, 
15)
 #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGSTARGET_IOR(BTRFS_IOCTL_MAGIC, 
25,\
abi_ullong)
 #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGSTARGET_IOW(BTRFS_IOCTL_MAGIC, 
26,\
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 0ce58d77727c..853b91d21275 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -358,7 +358,8 @@ STRUCT(blkpg_partition,
MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */
MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */
 
-#ifdef BTRFS_IOC_SUBVOL_CREATE
+#if defined(BTRFS_IOC_SUBVOL_CREATE) || defined(BTRFS_IOC_SNAP_CREATE) || \
+defined(BTRFS_IOC_SNAP_DESTROY)
 STRUCT(btrfs_ioctl_vol_args,
TYPE_LONGLONG, /* fd */
MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */
-- 
2.26.2




[PULL 9/9] linux-user: Add support for btrfs ioctls used to scrub a filesystem

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality for following ioctls:

BTRFS_IOC_SCRUB - Starting a btrfs filesystem scrub

Start a btrfs filesystem scrub. The third ioctls argument
is a pointer to a following type:

struct btrfs_ioctl_scrub_args {
__u64 devid;/* in */
__u64 start;/* in */
__u64 end;  /* in */
__u64 flags;/* in */
struct btrfs_scrub_progress progress;   /* out */
/* pad to 1k */
__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
};

Before calling this ioctl, field 'devid' should be filled
with value that represents the device id of the btrfs filesystem
for which the scrub is to be started.

BTRFS_IOC_SCRUB_CANCEL - Canceling scrub of a btrfs filesystem

Cancel a btrfs filesystem scrub if it is running. The third
ioctls argument is ignored.

BTRFS_IOC_SCRUB_PROGRESS - Getting status of a running scrub

Read the status of a running btrfs filesystem scrub. The third
ioctls argument is a pointer to the above mentioned
'struct btrfs_ioctl_scrub_args'. Similarly as with 'BTRFS_IOC_SCRUB',
the 'devid' field should be filled with value that represents the
id of the btrfs device for which the scrub has started. The status
of a running scrub is returned in the field 'progress' which is
of type 'struct btrfs_scrub_progress' and its definition can be
found at:

https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L150

Implementation nots:

Ioctls in this patch use type 'struct btrfs_ioctl_scrub_args' as their
third argument. That is the reason why an aproppriate thunk type
definition is added in file 'syscall_types.h'.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-9-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h| 11 +++
 linux-user/syscall_defs.h  |  3 +++
 linux-user/syscall_types.h | 29 +
 3 files changed, 43 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 42759c0778b4..585874f090ff 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -215,6 +215,17 @@
 #ifdef BTRFS_IOC_SUBVOL_SETFLAGS
  IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG))
 #endif
+#ifdef BTRFS_IOC_SCRUB
+ IOCTL(BTRFS_IOC_SCRUB, IOC_RW,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args)))
+#endif
+#ifdef BTRFS_IOC_SCRUB_CANCEL
+ IOCTL(BTRFS_IOC_SCRUB_CANCEL, 0, TYPE_NULL)
+#endif
+#ifdef BTRFS_IOC_SCRUB_PROGRESS
+ IOCTL(BTRFS_IOC_SCRUB_PROGRESS, IOC_RW,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args)))
+#endif
 #ifdef BTRFS_IOC_DEV_INFO
  IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index b557b07eec85..33a414c50f19 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1020,6 +1020,9 @@ struct target_rtc_pll_info {
abi_ullong)
 #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGSTARGET_IOW(BTRFS_IOCTL_MAGIC, 
26,\
abi_ullong)
+#define TARGET_BTRFS_IOC_SCRUB  
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 27)
+#define TARGET_BTRFS_IOC_SCRUB_CANCEL   TARGET_IO(BTRFS_IOCTL_MAGIC, 
28)
+#define TARGET_BTRFS_IOC_SCRUB_PROGRESS 
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 29)
 #define TARGET_BTRFS_IOC_DEV_INFO   
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30)
 #define TARGET_BTRFS_IOC_INO_PATHS  
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 35)
 #define TARGET_BTRFS_IOC_LOGICAL_INO
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 36)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 51d9931b9546..ba2c1518eb5c 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -425,6 +425,35 @@ STRUCT(btrfs_ioctl_ino_lookup_user_args,
MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */
 #endif
 
+#if defined(BTRFS_IOC_SCRUB) || defined(BTRFS_IOC_SCRUB_PROGRESS)
+STRUCT(btrfs_scrub_progress,
+   TYPE_ULONGLONG, /* data_extents_scrubbed */
+   TYPE_ULONGLONG, /* tree_extents_scrubbed */
+   TYPE_ULONGLONG, /* data_bytes_scrubbed */
+   TYPE_ULONGLONG, /* tree_bytes_scrubbed */
+   TYPE_ULONGLONG, /* read_errors */
+   TYPE_ULONGLONG, /* csum_errors */
+   TYPE_ULONGLONG, /* verify_errors */
+   TYPE_ULONGLONG, /* no_csum */
+   TYPE_ULONGLONG, /* csum_discards */
+   TYPE_ULONGLONG, /* super_errors */
+   TYPE_ULONGLONG, /* malloc_errors */
+   TYPE_ULONGLONG, /* uncorrectable_errors */
+   TYPE_ULONGLONG, /* corrected_er */
+   TYPE_ULONGLONG, /* last_physical */
+   

[PULL 4/9] linux-user: Add support for btrfs ioctls used to manipulate with devices

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality for following ioctls:

BTRFS_IOC_SCAN_DEV - Scanning device for a btrfs filesystem

Scan a device for a btrfs filesystem. The device that is to
be scanned is passed in the ioctl's third argument which
represents a pointer to a 'struct ioc_vol_args' (which was
mentioned in a previous patch). Before calling this ioctl,
the name field of this structure should be filled with the
aproppriate name value which represents a path for the device.
If the device contains a btrfs filesystem, the ioctl returns 0,
otherwise a negative value is returned.

BTRFS_IOC_ADD_DEV - Adding a device to a btrfs filesystem

Add a device to a btrfs filesystem. The device that is to be
added is passed in the ioctl's third argument which represents
a pointer to a 'struct ioc_vol_args' (which was mentioned in
a previous patch). Before calling this ioctl, the name field of
this structure should be filled with the aproppriate name value
which represents a path for the device.

BTRFS_IOC_RM_DEV - Removing a device from a btrfs filesystem

Remove a device from a btrfs filesystem. The device that is to be
removed is passed in the ioctl's third argument which represents
a pointer to a 'struct ioc_vol_args' (which was mentioned in
a previous patch). Before calling this ioctl, the name field of
this structure should be filled with the aproppriate name value
which represents a path for the device.

BTRFS_IOC_DEV_INFO - Getting information about a device

Obtain information for device in a btrfs filesystem. The information
is gathered in the ioctl's third argument which represents a pointer
to a following structure type:

struct btrfs_ioctl_dev_info_args {
__u64 devid;/* in/out */
__u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
__u64 bytes_used;   /* out */
__u64 total_bytes;  /* out */
__u64 unused[379];  /* pad to 4k */
__u8 path[BTRFS_DEVICE_PATH_NAME_MAX];  /* out */
};

Before calling this ioctl, field "devid" should be set with the id value
for the device for which the information is to be obtained. If this field
is not aproppriately set, the errno ENODEV ("No such device") is returned.

BTRFS_IOC_GET_DEV_STATS - Getting device statistics

Obtain stats informatin for device in a btrfs filesystem. The information
is gathered in the ioctl's third argument which represents a pointer to
a following structure type:

struct btrfs_ioctl_get_dev_stats {
__u64 devid;/* in */
__u64 nr_items; /* in/out */
__u64 flags;/* in/out */

/* out values: */
__u64 values[BTRFS_DEV_STAT_VALUES_MAX];

/*
 * This pads the struct to 1032 bytes. It was originally meant to pad to
 * 1024 bytes, but when adding the flags field, the padding calculation
 * was not adjusted.
 */
__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
};

Before calling this ioctl, field "devid" should be set with the id value
for the device for which the information is to be obtained. If this field
is not aproppriately set, the errno ENODEV ("No such device") is returned.

BTRFS_IOC_FORGET_DEV - Remove unmounted devices

Search and remove all stale devices (devices which are not mounted).
The third ioctl argument is a pointer to a 'struct btrfs_ioctl_vol_args'.
The ioctl call will release all unmounted devices which match the path
which is specified in the "name" field of the structure. If an empty
path ("") is specified, all unmounted devices will be released.

Implementation notes:

Ioctls BTRFS_IOC_DEV_INFO and BTRFS_IOC_GET_DEV_STATS use types
'struct btrfs_ioctl_dev_info_args' and ' struct btrfs_ioctl_get_dev_stats'
as third argument types. That is the reason why corresponding structure
definitions were added in file 'linux-user/syscall_types.h'.
Since the thunk type for 'struct ioc_vol_args' was already added in a
previous patch, the rest of the implementation was straightforward.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-4-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h| 24 
 linux-user/syscall_defs.h  |  6 ++
 linux-user/syscall_types.h | 24 +++-
 3 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index bddeaca9e7ec..74d73994f691 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -178,6 +178,22 @@
  IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
 #endif
+#ifdef BTRFS_IOC_SCAN_DEV
+

[PULL 1/9] linux-user: fix implicit conversion from enumeration type error

2020-09-02 Thread Laurent Vivier
MK_ARRAY(type,size) is used to fill the field_types buffer, and if the
"size" parameter is an enum type, clang [-Werror,-Wenum-conversion] reports
an error when it is assigned to field_types which is also an enum, argtypes.

To avoid that, convert "size" to "int" in MK_ARRAY(). "int" is the type
used for the size evaluation in thunk_type_size().

Signed-off-by: Laurent Vivier 
Message-Id: <20200902125752.1033524-1-laur...@vivier.eu>
---
 include/exec/user/thunk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h
index a5bbb2c73331..b281dfa30f8c 100644
--- a/include/exec/user/thunk.h
+++ b/include/exec/user/thunk.h
@@ -42,7 +42,7 @@ typedef enum argtype {
 } argtype;
 
 #define MK_PTR(type) TYPE_PTR, type
-#define MK_ARRAY(type, size) TYPE_ARRAY, size, type
+#define MK_ARRAY(type, size) TYPE_ARRAY, (int)(size), type
 #define MK_STRUCT(id) TYPE_STRUCT, id
 
 #define THUNK_TARGET 0
-- 
2.26.2




[PULL 5/9] linux-user: Add support for btrfs ioctls used to get/set features

2020-09-02 Thread Laurent Vivier
From: Filip Bozuta 

This patch implements functionality for following ioctls:

BTRFS_IOC_GET_FEATURES - Getting feature flags

Read feature flags for a btrfs filesystem. The feature flags
are returned inside the ioctl's third argument which represents
a pointer to a following structure type:

struct btrfs_ioctl_feature_flags {
__u64 compat_flags;
__u64 compat_ro_flags;
__u64 incompat_flags;
};

All of the structure field represent bit masks that can be composed
of values which can be found on:
https://elixir.bootlin.com/linux/latest/source/fs/btrfs/ctree.h#L282

BTRFS_IOC_SET_FEATURES - Setting feature flags

Set and clear feature flags for a btrfs filesystem. The feature flags
are set using the ioctl's third argument which represents a
'struct btrfs_ioctl_feature_flags[2]' array. The first element of the
array represent flags which are to be cleared and the second element of
the array represent flags which are to be set. The second element has the
priority over the first, which means that if there are matching flags
in the elements, they will be set in the filesystem. If the flag values
in the third argument aren't correctly set to be composed of the available
predefined flag values, errno ENOPERM ("Operation not permitted") is 
returned.

BTRFS_IOC_GET_SUPPORTED_FEATURES - Getting supported feature flags

Read supported feature flags for a btrfs filesystem. The supported
feature flags are read using the ioctl's third argument which represents
a 'struct btrfs_ioctl_feature_flags[3]' array. The first element of this
array represents all of the supported flags in the btrfs filesystem.
The second element represents flags that can be safely set and third element
represent flags that can be safely clearead.

Implementation notes:

All of the implemented ioctls use 'struct btrfs_ioctl_feature_flags' as
third argument. That is the reason why a corresponding defintion was added
in file 'linux-user/syscall_types.h'.

Signed-off-by: Filip Bozuta 
Tested-by: Daniel P. Berrangé 
Message-Id: <20200823195014.116226-5-filip.boz...@syrmia.com>
Signed-off-by: Laurent Vivier 
---
 linux-user/ioctls.h| 12 
 linux-user/syscall_defs.h  |  3 +++
 linux-user/syscall_types.h |  5 +
 3 files changed, 20 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 74d73994f691..11d7361848dd 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -216,6 +216,18 @@
  IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats)))
 #endif
+#ifdef BTRFS_IOC_GET_FEATURES
+ IOCTL(BTRFS_IOC_GET_FEATURES, IOC_R,
+   MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags)))
+#endif
+#ifdef BTRFS_IOC_SET_FEATURES
+ IOCTL(BTRFS_IOC_SET_FEATURES, IOC_W,
+   MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 2)))
+#endif
+#ifdef BTRFS_IOC_GET_SUPPORTED_FEATURES
+ IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R,
+   MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)))
+#endif
 #ifdef BTRFS_IOC_GET_SUBVOL_INFO
  IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index d11279b78bbe..f70138979704 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1019,6 +1019,9 @@ struct target_rtc_pll_info {
abi_ullong)
 #define TARGET_BTRFS_IOC_DEV_INFO   
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30)
 #define TARGET_BTRFS_IOC_GET_DEV_STATS  
TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 52)
+#define TARGET_BTRFS_IOC_GET_FEATURES   TARGET_IORU(BTRFS_IOCTL_MAGIC, 
57)
+#define TARGET_BTRFS_IOC_SET_FEATURES   TARGET_IOWU(BTRFS_IOCTL_MAGIC, 
57)
+#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 
57)
 #define TARGET_BTRFS_IOC_GET_SUBVOL_INFOTARGET_IORU(BTRFS_IOCTL_MAGIC, 
60)
 
 /* usb ioctls */
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 7e52b7aec5d9..eba0c43d4493 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -413,6 +413,11 @@ STRUCT(btrfs_ioctl_get_dev_stats,
 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */
 #endif
 
+STRUCT(btrfs_ioctl_feature_flags,
+   TYPE_ULONGLONG, /* compat_flags */
+   TYPE_ULONGLONG, /* compat_ro_flags */
+   TYPE_ULONGLONG) /* incompat_flags */
+
 STRUCT(rtc_time,
TYPE_INT, /* tm_sec */
TYPE_INT, /* tm_min */
-- 
2.26.2




[PULL 0/9] Linux user for 5.2 patches

2020-09-02 Thread Laurent Vivier
The following changes since commit 887adde81d1f1f3897f1688d37ec6851b4fdad86:

  Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' int=
o staging (2020-09-01 22:50:23 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/linux-user-for-5.2-pull-request

for you to fetch changes up to 9a5a5a05523651d4c887388a6e0d0e446ffb279d:

  linux-user: Add support for btrfs ioctls used to scrub a filesystem (2020-0=
9-03 01:09:35 +0200)


Add btrfs support
Fix MK_ARRAY()



Filip Bozuta (8):
  linux-user: Add support for a group of btrfs ioctls used for
subvolumes
  linux-user: Add support for a group of btrfs ioctls used for snapshots
  linux-user: Add support for btrfs ioctls used to manipulate with
devices
  linux-user: Add support for btrfs ioctls used to get/set features
  linux-user: Add support for a group of btrfs inode ioctls
  linux-user: Add support for two btrfs ioctls used for subvolume
  linux-user: Add support for btrfs ioctls used to manage quota
  linux-user: Add support for btrfs ioctls used to scrub a filesystem

Laurent Vivier (1):
  linux-user: fix implicit conversion from enumeration type error

 configure  |   9 ++
 include/exec/user/thunk.h  |   2 +-
 linux-user/ioctls.h| 124 
 linux-user/syscall.c   |   3 +
 linux-user/syscall_defs.h  |  37 +
 linux-user/syscall_types.h | 163 +
 6 files changed, 337 insertions(+), 1 deletion(-)

--=20
2.26.2




[PATCH 63/63] tests: Rename STATIC_TYPE to STATIC_PROPS

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: qemu-devel@nongnu.org
---
 tests/test-qdev-global-props.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index bf6b9fb2a2..ee4f561a5e 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -32,7 +32,7 @@
 
 #define TYPE_STATIC_PROPS "static_prop_type"
 typedef struct MyType MyType;
-DECLARE_INSTANCE_CHECKER(MyType, STATIC_TYPE,
+DECLARE_INSTANCE_CHECKER(MyType, STATIC_PROPS,
  TYPE_STATIC_PROPS)
 
 #define TYPE_SUBCLASS "static_prop_subtype"
@@ -77,7 +77,7 @@ static void test_static_prop_subprocess(void)
 {
 MyType *mt;
 
-mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
+mt = STATIC_PROPS(object_new(TYPE_STATIC_PROPS));
 qdev_realize(DEVICE(mt), NULL, _fatal);
 
 g_assert_cmpuint(mt->prop1, ==, PROP_DEFAULT);
@@ -112,7 +112,7 @@ static void test_static_globalprop_subprocess(void)
 
 register_global_properties(props);
 
-mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
+mt = STATIC_PROPS(object_new(TYPE_STATIC_PROPS));
 qdev_realize(DEVICE(mt), NULL, _fatal);
 
 g_assert_cmpuint(mt->prop1, ==, 200);
@@ -273,7 +273,7 @@ static void test_subclass_global_props(void)
 
 register_global_properties(props);
 
-mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
+mt = STATIC_PROPS(object_new(TYPE_SUBCLASS));
 qdev_realize(DEVICE(mt), NULL, _fatal);
 
 g_assert_cmpuint(mt->prop1, ==, 102);
-- 
2.26.2




Re: [PULL v2 00/76] target/microblaze improvements

2020-09-02 Thread Richard Henderson
On 9/2/20 12:09 PM, Thomas Huth wrote:
> On 01/09/2020 17.20, Richard Henderson wrote:
>> Version 2.  Serves me right for not testing 32-bit host
>> when I knew there was a patch that mattered.
> 
>  Hi Richard,
> 
> I'm afraid, but I think this PR broke the
> tests/acceptance/replay_kernel.py:ReplayKernel.test_microblaze_s3adsp1800 
> acceptance
> test:
> 
> https://gitlab.com/qemu-project/qemu/-/jobs/716158589#L176
> 
> Could you please have a look?

That's odd.

Doesn't replay rely on migration (or at least VMStateDescription) to do its
job?  Microblaze doesn't implement that, so how could this have worked before?

I admit that I don't often run check-acceptance, because I rarely see a clean
bill of health, even for stuff I'm not working on.

Looking into it...


r~



[PATCH 57/63] xen: Rename XENBACKEND_DEVICE to XENBACKEND

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefano Stabellini 
Cc: Anthony Perard 
Cc: Paul Durrant 
Cc: xen-de...@lists.xenproject.org
Cc: qemu-devel@nongnu.org
---
 include/hw/xen/xen-legacy-backend.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/xen/xen-legacy-backend.h 
b/include/hw/xen/xen-legacy-backend.h
index ba7a3c59bb..be281e1f38 100644
--- a/include/hw/xen/xen-legacy-backend.h
+++ b/include/hw/xen/xen-legacy-backend.h
@@ -11,7 +11,7 @@
 #define TYPE_XENBACKEND "xen-backend"
 
 typedef struct XenLegacyDevice XenLegacyDevice;
-DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND_DEVICE,
+DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND,
  TYPE_XENBACKEND)
 
 /* variables */
-- 
2.26.2




[REPORT] Nightly Performance Tests - Wednesday, September 2, 2020

2020-09-02 Thread Ahmed Karaman

Host CPU : Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Host Memory  : 15.49 GB

Start Time (UTC) : 2020-09-02 22:30:02
End Time (UTC)   : 2020-09-02 23:02:38
Execution Time   : 0:32:36.315663

Status   : SUCCESS

Note:
Changes denoted by '-' are less than 0.01%.


SUMMARY REPORT - COMMIT ed215cec

AVERAGE RESULTS

Target  Instructions  Latest  v5.1.0
--    --  --
aarch642 158 360 930   - +1.694%
alpha  1 914 970 396   - +3.524%
arm8 076 521 559   - +2.308%
hppa   4 261 655 888   - +3.162%
m68k   2 690 291 454   - +7.134%
mips   1 862 055 271   - +2.495%
mipsel 2 008 237 057   - +2.676%
mips64 1 918 627 557   - +2.818%
mips64el   2 051 536 272   - +3.024%
ppc2 480 160 545   - +3.108%
ppc64  2 576 707 600   - +3.142%
ppc64le2 558 869 865   - +3.174%
riscv641 406 710 004   -  +2.65%
s390x  3 158 126 452   - +3.118%
sh42 364 458 094   - +3.331%
sparc643 318 800 942   -  +3.86%
x86_64 1 775 807 445   - +2.156%


   DETAILED RESULTS

Test Program: dijkstra_double

Target  Instructions  Latest  v5.1.0
--    --  --
aarch643 062 596 104   - +1.424%
alpha  3 191 868 433   - +3.696%
arm   16 357 285 680   - +2.348%
hppa   7 228 372 058   - +3.086%
m68k   4 294 057 266   - +9.693%
mips   3 051 467 316   - +2.428%
mipsel 3 231 546 158   -  +2.87%
mips64 3 245 820 632   - +2.596%
mips64el   3 414 198 738   - +3.021%
ppc4 914 545 594   -  +4.74%
ppc64  5 098 147 494   - +4.565%
ppc64le5 082 438 783   -  +4.58%
riscv642 192 294 741   - +1.955%
s390x  4 584 575 668   - +2.897%
sh43 949 047 124   - +3.464%
sparc644 586 207 238   - +4.237%
x86_64 2 484 112 825   - +1.751%


Test Program: dijkstra_int32

Target  Instructions  Latest  v5.1.0
--    --  --
aarch642 210 209 502   - +1.494%
alpha  1 494 136 649   - +2.151%
arm8 263 038 159   - +2.667%
hppa   5 207 287 269   - +3.046%
m68k   1 725 878 249   - +2.528%
mips   1 495 262 663   - +1.494%
mipsel 1 497 165 654   -  +1.48%
mips64 1 715 423 109   - +1.894%
mips64el   1 695 190 855   - +1.908%
ppc2 014 586 104   - +1.821%
ppc64  2 206 261 948   - +2.138%
ppc64le2 198 014 858   - +2.147%
riscv641 354 904 958   - +2.395%
s390x  2 916 083 991   - +1.236%
sh41 990 545 700   -  +2.67%
sparc642 874 242 969   -  +3.83%
x86_64 1 554 003 185   - +2.121%


Test Program: matmult_double

Target  Instructions  Latest  v5.1.0
--    --  --
aarch641 412 263 878   - +0.301%
alpha  3 233 995 126   - +7.473%
arm8 545 296 938   -  +1.09%
hppa   3 483 500 827   - +4.466%
m68k   3 919 108 993   -+18.433%
mips   2 344 799 492   - +4.092%
mipsel 3 329 919 049   - +5.178%
mips64 2 359 033 307   - +4.075%

[PATCH 55/63] vfio: Rename PCI_VFIO to VFIO_PCI

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Alex Williamson 
Cc: qemu-devel@nongnu.org
---
 hw/vfio/pci.h |  2 +-
 hw/vfio/pci.c | 22 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 846d60e56c..5e53d5b863 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -116,7 +116,7 @@ typedef struct VFIOMSIXInfo {
 
 #define TYPE_VFIO_PCI "vfio-pci"
 typedef struct VFIOPCIDevice VFIOPCIDevice;
-DECLARE_INSTANCE_CHECKER(VFIOPCIDevice, PCI_VFIO,
+DECLARE_INSTANCE_CHECKER(VFIOPCIDevice, VFIO_PCI,
  TYPE_VFIO_PCI)
 
 struct VFIOPCIDevice {
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 3611dcd38b..0d83eb0e47 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -230,7 +230,7 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, 
PCIINTxRoute *route)
 
 static void vfio_intx_routing_notifier(PCIDevice *pdev)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 PCIINTxRoute route;
 
 if (vdev->interrupt != VFIO_INT_INTx) {
@@ -456,7 +456,7 @@ static void vfio_update_kvm_msi_virq(VFIOMSIVector *vector, 
MSIMessage msg,
 static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
MSIMessage *msg, IOHandler *handler)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 VFIOMSIVector *vector;
 int ret;
 
@@ -541,7 +541,7 @@ static int vfio_msix_vector_use(PCIDevice *pdev,
 
 static void vfio_msix_vector_release(PCIDevice *pdev, unsigned int nr)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 VFIOMSIVector *vector = >msi_vectors[nr];
 
 trace_vfio_msix_vector_release(vdev->vbasedev.name, nr);
@@ -1048,7 +1048,7 @@ static const MemoryRegionOps vfio_vga_ops = {
  */
 static void vfio_sub_page_bar_update_mapping(PCIDevice *pdev, int bar)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 VFIORegion *region = >bars[bar].region;
 MemoryRegion *mmap_mr, *region_mr, *base_mr;
 PCIIORegion *r;
@@ -1094,7 +1094,7 @@ static void vfio_sub_page_bar_update_mapping(PCIDevice 
*pdev, int bar)
  */
 uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 uint32_t emu_bits = 0, emu_val = 0, phys_val = 0, val;
 
 memcpy(_bits, vdev->emulated_config_bits + addr, len);
@@ -1127,7 +1127,7 @@ uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t 
addr, int len)
 void vfio_pci_write_config(PCIDevice *pdev,
uint32_t addr, uint32_t val, int len)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 uint32_t val_le = cpu_to_le32(val);
 
 trace_vfio_pci_write_config(vdev->vbasedev.name, addr, val, len);
@@ -2701,7 +2701,7 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice 
*vdev)
 
 static void vfio_realize(PCIDevice *pdev, Error **errp)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 VFIODevice *vbasedev_iter;
 VFIOGroup *group;
 char *tmp, *subsys, group_path[PATH_MAX], *group_name;
@@ -3033,7 +3033,7 @@ error:
 
 static void vfio_instance_finalize(Object *obj)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(obj);
+VFIOPCIDevice *vdev = VFIO_PCI(obj);
 VFIOGroup *group = vdev->vbasedev.group;
 
 vfio_display_finalize(vdev);
@@ -3057,7 +3057,7 @@ static void vfio_instance_finalize(Object *obj)
 
 static void vfio_exitfn(PCIDevice *pdev)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(pdev);
+VFIOPCIDevice *vdev = VFIO_PCI(pdev);
 
 vfio_unregister_req_notifier(vdev);
 vfio_unregister_err_notifier(vdev);
@@ -3075,7 +3075,7 @@ static void vfio_exitfn(PCIDevice *pdev)
 
 static void vfio_pci_reset(DeviceState *dev)
 {
-VFIOPCIDevice *vdev = PCI_VFIO(dev);
+VFIOPCIDevice *vdev = VFIO_PCI(dev);
 
 trace_vfio_pci_reset(vdev->vbasedev.name);
 
@@ -3115,7 +3115,7 @@ post_reset:
 static void vfio_instance_init(Object *obj)
 {
 PCIDevice *pci_dev = PCI_DEVICE(obj);
-VFIOPCIDevice *vdev = PCI_VFIO(obj);
+VFIOPCIDevice *vdev = VFIO_PCI(obj);
 
 device_add_bootindex_property(obj, >bootindex,
   "bootindex", NULL,
-- 
2.26.2




[PATCH 62/63] tests: Rename DYNAMIC_TYPE to DYNAMIC_PROPS

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: qemu-devel@nongnu.org
---
 tests/test-qdev-global-props.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index 8a3c14d92c..bf6b9fb2a2 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -128,7 +128,7 @@ static void test_static_globalprop(void)
 }
 
 #define TYPE_DYNAMIC_PROPS "dynamic-prop-type"
-DECLARE_INSTANCE_CHECKER(MyType, DYNAMIC_TYPE,
+DECLARE_INSTANCE_CHECKER(MyType, DYNAMIC_PROPS,
  TYPE_DYNAMIC_PROPS)
 
 #define TYPE_UNUSED_HOTPLUG   "hotplug-type"
@@ -137,7 +137,7 @@ DECLARE_INSTANCE_CHECKER(MyType, DYNAMIC_TYPE,
 static void prop1_accessor(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-MyType *mt = DYNAMIC_TYPE(obj);
+MyType *mt = DYNAMIC_PROPS(obj);
 
 visit_type_uint32(v, name, >prop1, errp);
 }
@@ -145,7 +145,7 @@ static void prop1_accessor(Object *obj, Visitor *v, const 
char *name,
 static void prop2_accessor(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
 {
-MyType *mt = DYNAMIC_TYPE(obj);
+MyType *mt = DYNAMIC_PROPS(obj);
 
 visit_type_uint32(v, name, >prop2, errp);
 }
@@ -230,7 +230,7 @@ static void test_dynamic_globalprop_subprocess(void)
 
 register_global_properties(props);
 
-mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
+mt = DYNAMIC_PROPS(object_new(TYPE_DYNAMIC_PROPS));
 qdev_realize(DEVICE(mt), NULL, _fatal);
 
 g_assert_cmpuint(mt->prop1, ==, 101);
-- 
2.26.2




[PATCH 54/63] usb: Rename USB_STORAGE_DEV to USB_STORAGE

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/usb/dev-storage.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 648340323f..bbc5d904bf 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -70,7 +70,7 @@ struct MSDState {
 typedef struct MSDState MSDState;
 
 #define TYPE_USB_STORAGE "usb-storage-dev"
-DECLARE_INSTANCE_CHECKER(MSDState, USB_STORAGE_DEV,
+DECLARE_INSTANCE_CHECKER(MSDState, USB_STORAGE,
  TYPE_USB_STORAGE)
 
 struct usb_msd_cbw {
@@ -400,7 +400,7 @@ static void usb_msd_handle_control(USBDevice *dev, 
USBPacket *p,
 
 static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p)
 {
-MSDState *s = USB_STORAGE_DEV(dev);
+MSDState *s = USB_STORAGE(dev);
 
 assert(s->packet == p);
 s->packet = NULL;
@@ -605,7 +605,7 @@ static const struct SCSIBusInfo usb_msd_scsi_info_bot = {
 
 static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
 {
-MSDState *s = USB_STORAGE_DEV(dev);
+MSDState *s = USB_STORAGE(dev);
 BlockBackend *blk = s->conf.blk;
 SCSIDevice *scsi_dev;
 
@@ -656,7 +656,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error 
**errp)
 
 static void usb_msd_bot_realize(USBDevice *dev, Error **errp)
 {
-MSDState *s = USB_STORAGE_DEV(dev);
+MSDState *s = USB_STORAGE(dev);
 DeviceState *d = DEVICE(dev);
 
 usb_desc_create_serial(dev);
@@ -725,7 +725,7 @@ static void usb_msd_get_bootindex(Object *obj, Visitor *v, 
const char *name,
   void *opaque, Error **errp)
 {
 USBDevice *dev = USB_DEVICE(obj);
-MSDState *s = USB_STORAGE_DEV(dev);
+MSDState *s = USB_STORAGE(dev);
 
 visit_type_int32(v, name, >conf.bootindex, errp);
 }
@@ -734,7 +734,7 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, 
const char *name,
   void *opaque, Error **errp)
 {
 USBDevice *dev = USB_DEVICE(obj);
-MSDState *s = USB_STORAGE_DEV(dev);
+MSDState *s = USB_STORAGE(dev);
 int32_t boot_index;
 Error *local_err = NULL;
 
-- 
2.26.2




[PATCH 56/63] vmxnet3: Rename VMXNET3_DEVICE* to VMXNET3*

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Dmitry Fleytman 
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 hw/net/vmxnet3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index eff299f629..100e5982d0 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -135,7 +135,7 @@ struct VMXNET3Class {
 };
 typedef struct VMXNET3Class VMXNET3Class;
 
-DECLARE_CLASS_CHECKERS(VMXNET3Class, VMXNET3_DEVICE,
+DECLARE_CLASS_CHECKERS(VMXNET3Class, VMXNET3,
TYPE_VMXNET3)
 
 static inline void vmxnet3_ring_init(PCIDevice *d,
@@ -2475,7 +2475,7 @@ static Property vmxnet3_properties[] = {
 
 static void vmxnet3_realize(DeviceState *qdev, Error **errp)
 {
-VMXNET3Class *vc = VMXNET3_DEVICE_GET_CLASS(qdev);
+VMXNET3Class *vc = VMXNET3_GET_CLASS(qdev);
 PCIDevice *pci_dev = PCI_DEVICE(qdev);
 VMXNET3State *s = VMXNET3(qdev);
 
@@ -2490,7 +2490,7 @@ static void vmxnet3_class_init(ObjectClass *class, void 
*data)
 {
 DeviceClass *dc = DEVICE_CLASS(class);
 PCIDeviceClass *c = PCI_DEVICE_CLASS(class);
-VMXNET3Class *vc = VMXNET3_DEVICE_CLASS(class);
+VMXNET3Class *vc = VMXNET3_CLASS(class);
 
 c->realize = vmxnet3_pci_realize;
 c->exit = vmxnet3_pci_uninit;
-- 
2.26.2




[PATCH 53/63] usb: Rename USB_SERIAL_DEV to USB_SERIAL

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: Samuel Thibault 
Cc: qemu-devel@nongnu.org
---
 hw/usb/dev-serial.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 1a58851d4b..1a038a222e 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -113,7 +113,7 @@ struct USBSerialState {
 typedef struct USBSerialState USBSerialState;
 
 #define TYPE_USB_SERIAL "usb-serial-dev"
-DECLARE_INSTANCE_CHECKER(USBSerialState, USB_SERIAL_DEV,
+DECLARE_INSTANCE_CHECKER(USBSerialState, USB_SERIAL,
  TYPE_USB_SERIAL)
 
 enum {
@@ -517,7 +517,7 @@ static void usb_serial_event(void *opaque, QEMUChrEvent 
event)
 
 static void usb_serial_realize(USBDevice *dev, Error **errp)
 {
-USBSerialState *s = USB_SERIAL_DEV(dev);
+USBSerialState *s = USB_SERIAL(dev);
 Error *local_err = NULL;
 
 usb_desc_create_serial(dev);
-- 
2.26.2




[PATCH 61/63] tests: Rename TYPE_DUMMY to TYPE_DUMMY_OBJECT

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: "Daniel P. Berrangé" 
Cc: Eduardo Habkost 
Cc: qemu-devel@nongnu.org
---
 tests/check-qom-proplist.c | 30 +++---
 tests/test-io-task.c   | 14 +++---
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 1571606c1c..b4b31c57d3 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -28,13 +28,13 @@
 #include "qom/object_interfaces.h"
 
 
-#define TYPE_DUMMY "qemu-dummy"
+#define TYPE_DUMMY_OBJECT "qemu-dummy"
 
 typedef struct DummyObject DummyObject;
 typedef struct DummyObjectClass DummyObjectClass;
 
 DECLARE_INSTANCE_CHECKER(DummyObject, DUMMY_OBJECT,
- TYPE_DUMMY)
+ TYPE_DUMMY_OBJECT)
 
 typedef enum DummyAnimal DummyAnimal;
 
@@ -153,7 +153,7 @@ static void dummy_finalize(Object *obj)
 
 
 static const TypeInfo dummy_info = {
-.name  = TYPE_DUMMY,
+.name  = TYPE_DUMMY_OBJECT,
 .parent= TYPE_OBJECT,
 .instance_size = sizeof(DummyObject),
 .instance_init = dummy_init,
@@ -337,7 +337,7 @@ static void test_dummy_createv(void)
 Error *err = NULL;
 Object *parent = object_get_objects_root();
 DummyObject *dobj = DUMMY_OBJECT(
-object_new_with_props(TYPE_DUMMY,
+object_new_with_props(TYPE_DUMMY_OBJECT,
   parent,
   "dummy0",
   ,
@@ -366,7 +366,7 @@ static Object *new_helper(Error **errp,
 Object *obj;
 
 va_start(vargs, parent);
-obj = object_new_with_propv(TYPE_DUMMY,
+obj = object_new_with_propv(TYPE_DUMMY_OBJECT,
 parent,
 "dummy0",
 errp,
@@ -403,7 +403,7 @@ static void test_dummy_createcmdl(void)
 QemuOpts *opts;
 DummyObject *dobj;
 Error *err = NULL;
-const char *params = TYPE_DUMMY \
+const char *params = TYPE_DUMMY_OBJECT \
  ",id=dev0," \
  "bv=yes,sv=Hiss hiss hiss,av=platypus";
 
@@ -443,7 +443,7 @@ static void test_dummy_badenum(void)
 Error *err = NULL;
 Object *parent = object_get_objects_root();
 Object *dobj =
-object_new_with_props(TYPE_DUMMY,
+object_new_with_props(TYPE_DUMMY_OBJECT,
   parent,
   "dummy0",
   ,
@@ -470,7 +470,7 @@ static void test_dummy_getenum(void)
 int val;
 Object *parent = object_get_objects_root();
 DummyObject *dobj = DUMMY_OBJECT(
-object_new_with_props(TYPE_DUMMY,
+object_new_with_props(TYPE_DUMMY_OBJECT,
  parent,
  "dummy0",
  ,
@@ -533,7 +533,7 @@ static void test_dummy_iterator(void)
 "bv"};  /* instance property */
 Object *parent = object_get_objects_root();
 DummyObject *dobj = DUMMY_OBJECT(
-object_new_with_props(TYPE_DUMMY,
+object_new_with_props(TYPE_DUMMY_OBJECT,
   parent,
   "dummy0",
   _abort,
@@ -552,7 +552,7 @@ static void test_dummy_class_iterator(void)
 {
 const char *expected[] = { "type", "av", "sv" };
 ObjectPropertyIterator iter;
-ObjectClass *klass = object_class_by_name(TYPE_DUMMY);
+ObjectClass *klass = object_class_by_name(TYPE_DUMMY_OBJECT);
 
 object_class_property_iter_init(, klass);
 test_dummy_prop_iterator(, expected, ARRAY_SIZE(expected));
@@ -575,9 +575,9 @@ static void test_qom_partial_path(void)
 {
 Object *root  = object_get_objects_root();
 Object *cont1 = container_get(root, "/cont1");
-Object *obj1  = object_new(TYPE_DUMMY);
-Object *obj2a = object_new(TYPE_DUMMY);
-Object *obj2b = object_new(TYPE_DUMMY);
+Object *obj1  = object_new(TYPE_DUMMY_OBJECT);
+Object *obj2a = object_new(TYPE_DUMMY_OBJECT);
+Object *obj2b = object_new(TYPE_DUMMY_OBJECT);
 bool ambiguous;
 
 /* Objects created:
@@ -594,9 +594,9 @@ static void test_qom_partial_path(void)
 object_unref(obj2b);
 
 ambiguous = false;
-g_assert(!object_resolve_path_type("", TYPE_DUMMY, ));
+g_assert(!object_resolve_path_type("", TYPE_DUMMY_OBJECT, ));
 g_assert(ambiguous);
-g_assert(!object_resolve_path_type("", TYPE_DUMMY, NULL));
+g_assert(!object_resolve_path_type("", TYPE_DUMMY_OBJECT, NULL));
 
 ambiguous = false;
 g_assert(!object_resolve_path("obj2", ));
diff --git a/tests/test-io-task.c b/tests/test-io-task.c
index 85e7a98da5..74b60f951a 100644
--- a/tests/test-io-task.c
+++ b/tests/test-io-task.c
@@ -25,7 +25,7 @@
 #include "qapi/error.h"
 #include "qemu/module.h"
 

[PATCH 51/63] tpm_spapr: Rename VIO_SPAPR_VTPM to TPM_SPAPR

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: qemu-devel@nongnu.org
---
 hw/tpm/tpm_spapr.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c
index e3775adc57..aa86d5f943 100644
--- a/hw/tpm/tpm_spapr.c
+++ b/hw/tpm/tpm_spapr.c
@@ -31,7 +31,7 @@
 #define DEBUG_SPAPR 0
 
 typedef struct SpaprTpmState SpaprTpmState;
-DECLARE_INSTANCE_CHECKER(SpaprTpmState, VIO_SPAPR_VTPM,
+DECLARE_INSTANCE_CHECKER(SpaprTpmState, TPM_SPAPR,
  TYPE_TPM_SPAPR)
 
 typedef struct TpmCrq {
@@ -132,7 +132,7 @@ static inline int spapr_tpm_send_crq(struct SpaprVioDevice 
*dev, TpmCrq *crq)
 
 static int tpm_spapr_do_crq(struct SpaprVioDevice *dev, uint8_t *crq_data)
 {
-SpaprTpmState *s = VIO_SPAPR_VTPM(dev);
+SpaprTpmState *s = TPM_SPAPR(dev);
 TpmCrq local_crq;
 TpmCrq *crq = >crq; /* requests only */
 int rc;
@@ -235,7 +235,7 @@ static int tpm_spapr_do_crq(struct SpaprVioDevice *dev, 
uint8_t *crq_data)
 
 static void tpm_spapr_request_completed(TPMIf *ti, int ret)
 {
-SpaprTpmState *s = VIO_SPAPR_VTPM(ti);
+SpaprTpmState *s = TPM_SPAPR(ti);
 TpmCrq *crq = >crq;
 uint32_t len;
 int rc;
@@ -283,7 +283,7 @@ static int tpm_spapr_do_startup_tpm(SpaprTpmState *s, 
size_t buffersize)
 
 static const char *tpm_spapr_get_dt_compatible(SpaprVioDevice *dev)
 {
-SpaprTpmState *s = VIO_SPAPR_VTPM(dev);
+SpaprTpmState *s = TPM_SPAPR(dev);
 
 switch (s->be_tpm_version) {
 case TPM_VERSION_1_2:
@@ -297,7 +297,7 @@ static const char 
*tpm_spapr_get_dt_compatible(SpaprVioDevice *dev)
 
 static void tpm_spapr_reset(SpaprVioDevice *dev)
 {
-SpaprTpmState *s = VIO_SPAPR_VTPM(dev);
+SpaprTpmState *s = TPM_SPAPR(dev);
 
 s->state = SPAPR_VTPM_STATE_NONE;
 s->numbytes = 0;
@@ -316,7 +316,7 @@ static void tpm_spapr_reset(SpaprVioDevice *dev)
 
 static enum TPMVersion tpm_spapr_get_version(TPMIf *ti)
 {
-SpaprTpmState *s = VIO_SPAPR_VTPM(ti);
+SpaprTpmState *s = TPM_SPAPR(ti);
 
 if (tpm_backend_had_startup_error(s->be_driver)) {
 return TPM_VERSION_UNSPEC;
@@ -377,7 +377,7 @@ static Property tpm_spapr_properties[] = {
 
 static void tpm_spapr_realizefn(SpaprVioDevice *dev, Error **errp)
 {
-SpaprTpmState *s = VIO_SPAPR_VTPM(dev);
+SpaprTpmState *s = TPM_SPAPR(dev);
 
 if (!tpm_find()) {
 error_setg(errp, "at most one TPM device is permitted");
-- 
2.26.2




[PATCH 48/63] sabre: Rename SABRE_DEVICE to SABRE

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-devel@nongnu.org
---
 include/hw/pci-host/sabre.h | 2 +-
 hw/pci-host/sabre.c | 8 
 hw/sparc64/sun4u.c  | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/hw/pci-host/sabre.h b/include/hw/pci-host/sabre.h
index 597bf70d69..7a76de4b9e 100644
--- a/include/hw/pci-host/sabre.h
+++ b/include/hw/pci-host/sabre.h
@@ -51,7 +51,7 @@ struct SabreState {
 typedef struct SabreState SabreState;
 
 #define TYPE_SABRE "sabre"
-DECLARE_INSTANCE_CHECKER(SabreState, SABRE_DEVICE,
+DECLARE_INSTANCE_CHECKER(SabreState, SABRE,
  TYPE_SABRE)
 
 #endif
diff --git a/hw/pci-host/sabre.c b/hw/pci-host/sabre.c
index 0cc68585f8..5ac6283623 100644
--- a/hw/pci-host/sabre.c
+++ b/hw/pci-host/sabre.c
@@ -338,7 +338,7 @@ static void pci_sabre_set_irq(void *opaque, int irq_num, 
int level)
 
 static void sabre_reset(DeviceState *d)
 {
-SabreState *s = SABRE_DEVICE(d);
+SabreState *s = SABRE(d);
 PCIDevice *pci_dev;
 unsigned int i;
 uint16_t cmd;
@@ -376,7 +376,7 @@ static const MemoryRegionOps pci_config_ops = {
 
 static void sabre_realize(DeviceState *dev, Error **errp)
 {
-SabreState *s = SABRE_DEVICE(dev);
+SabreState *s = SABRE(dev);
 PCIHostState *phb = PCI_HOST_BRIDGE(dev);
 SysBusDevice *sbd = SYS_BUS_DEVICE(s);
 PCIDevice *pci_dev;
@@ -421,7 +421,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
 
 static void sabre_init(Object *obj)
 {
-SabreState *s = SABRE_DEVICE(obj);
+SabreState *s = SABRE(obj);
 SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
 unsigned int i;
 
@@ -502,7 +502,7 @@ static const TypeInfo sabre_pci_info = {
 
 static char *sabre_ofw_unit_address(const SysBusDevice *dev)
 {
-SabreState *s = SABRE_DEVICE(dev);
+SabreState *s = SABRE(dev);
 
 return g_strdup_printf("%x,%x",
(uint32_t)((s->special_base >> 32) & 0x),
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index fe0d84bf6c..b746c3bf38 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -585,7 +585,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
 prom_init(hwdef->prom_addr, bios_name);
 
 /* Init sabre (PCI host bridge) */
-sabre = SABRE_DEVICE(qdev_new(TYPE_SABRE));
+sabre = SABRE(qdev_new(TYPE_SABRE));
 qdev_prop_set_uint64(DEVICE(sabre), "special-base", PBM_SPECIAL_BASE);
 qdev_prop_set_uint64(DEVICE(sabre), "mem-base", PBM_MEM_BASE);
 object_property_set_link(OBJECT(sabre), "iommu", OBJECT(iommu),
-- 
2.26.2




[PATCH 60/63] tcg: Rename TCG_STATE to TCG_ACCEL

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Richard Henderson 
Cc: Paolo Bonzini 
Cc: qemu-devel@nongnu.org
---
 accel/tcg/tcg-all.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 7098ad96c3..08d82e5c03 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -46,7 +46,7 @@ typedef struct TCGState TCGState;
 
 #define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
 
-DECLARE_INSTANCE_CHECKER(TCGState, TCG_STATE,
+DECLARE_INSTANCE_CHECKER(TCGState, TCG_ACCEL,
  TYPE_TCG_ACCEL)
 
 /* mask must never be zero, except for A20 change call */
@@ -118,14 +118,14 @@ static bool default_mttcg_enabled(void)
 
 static void tcg_accel_instance_init(Object *obj)
 {
-TCGState *s = TCG_STATE(obj);
+TCGState *s = TCG_ACCEL(obj);
 
 s->mttcg_enabled = default_mttcg_enabled();
 }
 
 static int tcg_init(MachineState *ms)
 {
-TCGState *s = TCG_STATE(current_accel());
+TCGState *s = TCG_ACCEL(current_accel());
 
 tcg_exec_init(s->tb_size * 1024 * 1024);
 cpu_interrupt_handler = tcg_handle_interrupt;
@@ -135,14 +135,14 @@ static int tcg_init(MachineState *ms)
 
 static char *tcg_get_thread(Object *obj, Error **errp)
 {
-TCGState *s = TCG_STATE(obj);
+TCGState *s = TCG_ACCEL(obj);
 
 return g_strdup(s->mttcg_enabled ? "multi" : "single");
 }
 
 static void tcg_set_thread(Object *obj, const char *value, Error **errp)
 {
-TCGState *s = TCG_STATE(obj);
+TCGState *s = TCG_ACCEL(obj);
 
 if (strcmp(value, "multi") == 0) {
 if (TCG_OVERSIZED_GUEST) {
@@ -172,7 +172,7 @@ static void tcg_get_tb_size(Object *obj, Visitor *v,
 const char *name, void *opaque,
 Error **errp)
 {
-TCGState *s = TCG_STATE(obj);
+TCGState *s = TCG_ACCEL(obj);
 uint32_t value = s->tb_size;
 
 visit_type_uint32(v, name, , errp);
@@ -182,7 +182,7 @@ static void tcg_set_tb_size(Object *obj, Visitor *v,
 const char *name, void *opaque,
 Error **errp)
 {
-TCGState *s = TCG_STATE(obj);
+TCGState *s = TCG_ACCEL(obj);
 uint32_t value;
 
 if (!visit_type_uint32(v, name, , errp)) {
-- 
2.26.2




[PATCH 52/63] usb: Rename USB_REDIRECT to USB_REDIR

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/usb/redirect.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index a079ecd50c..721af75da4 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -145,7 +145,7 @@ struct USBRedirDevice {
 };
 
 #define TYPE_USB_REDIR "usb-redir"
-DECLARE_INSTANCE_CHECKER(USBRedirDevice, USB_REDIRECT,
+DECLARE_INSTANCE_CHECKER(USBRedirDevice, USB_REDIR,
  TYPE_USB_REDIR)
 
 static void usbredir_hello(void *priv, struct usb_redir_hello_header *h);
@@ -375,7 +375,7 @@ static void packet_id_queue_empty(struct PacketIdQueue *q)
 
 static void usbredir_cancel_packet(USBDevice *udev, USBPacket *p)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 int i = USBEP2I(p->ep);
 
 if (p->combined) {
@@ -516,7 +516,7 @@ static void usbredir_free_bufpq(USBRedirDevice *dev, 
uint8_t ep)
 
 static void usbredir_handle_reset(USBDevice *udev)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 
 DPRINTF("reset device\n");
 usbredirparser_send_reset(dev->parser);
@@ -955,7 +955,7 @@ static void 
usbredir_stop_interrupt_receiving(USBRedirDevice *dev,
 
 static void usbredir_handle_data(USBDevice *udev, USBPacket *p)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 uint8_t ep;
 
 ep = p->ep->nr;
@@ -1024,7 +1024,7 @@ static void usbredir_stop_ep(USBRedirDevice *dev, int i)
 
 static void usbredir_ep_stopped(USBDevice *udev, USBEndpoint *uep)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 
 usbredir_stop_ep(dev, USBEP2I(uep));
 usbredirparser_do_write(dev->parser);
@@ -1094,7 +1094,7 @@ static void usbredir_get_interface(USBRedirDevice *dev, 
USBPacket *p,
 static void usbredir_handle_control(USBDevice *udev, USBPacket *p,
 int request, int value, int index, int length, uint8_t *data)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 struct usb_redir_control_packet_header control_packet;
 
 if (usbredir_already_in_flight(dev, p->id)) {
@@ -1149,7 +1149,7 @@ static void usbredir_handle_control(USBDevice *udev, 
USBPacket *p,
 static int usbredir_alloc_streams(USBDevice *udev, USBEndpoint **eps,
   int nr_eps, int streams)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 #if USBREDIR_VERSION >= 0x000700
 struct usb_redir_alloc_bulk_streams_header alloc_streams;
 int i;
@@ -1188,7 +1188,7 @@ static void usbredir_free_streams(USBDevice *udev, 
USBEndpoint **eps,
   int nr_eps)
 {
 #if USBREDIR_VERSION >= 0x000700
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 struct usb_redir_free_bulk_streams_header free_streams;
 int i;
 
@@ -1417,7 +1417,7 @@ static void usbredir_init_endpoints(USBRedirDevice *dev)
 
 static void usbredir_realize(USBDevice *udev, Error **errp)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 int i;
 
 if (!qemu_chr_fe_backend_connected(>cs)) {
@@ -1472,7 +1472,7 @@ static void usbredir_cleanup_device_queues(USBRedirDevice 
*dev)
 
 static void usbredir_unrealize(USBDevice *udev)
 {
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 
 qemu_chr_fe_deinit(>cs, true);
 
@@ -2593,7 +2593,7 @@ static void usbredir_class_initfn(ObjectClass *klass, 
void *data)
 static void usbredir_instance_init(Object *obj)
 {
 USBDevice *udev = USB_DEVICE(obj);
-USBRedirDevice *dev = USB_REDIRECT(udev);
+USBRedirDevice *dev = USB_REDIR(udev);
 
 device_add_bootindex_property(obj, >bootindex,
   "bootindex", NULL,
-- 
2.26.2




[PATCH 58/63] hvf: Rename HVF_STATE to HVF_ACCEL

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Cameron Esfahani 
Cc: Roman Bolshakov 
Cc: qemu-devel@nongnu.org
---
 include/sysemu/hvf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
index 1398679458..195795e857 100644
--- a/include/sysemu/hvf.h
+++ b/include/sysemu/hvf.h
@@ -37,7 +37,7 @@ void hvf_vcpu_destroy(CPUState *);
 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
 
 typedef struct HVFState HVFState;
-DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE,
+DECLARE_INSTANCE_CHECKER(HVFState, HVF_ACCEL,
  TYPE_HVF_ACCEL)
 
 #endif
-- 
2.26.2




[PATCH 42/63] lasi_i82596: Rename SYSBUS_I82596 to LASI_82596

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Richard Henderson 
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 include/hw/net/lasi_82596.h | 2 +-
 hw/net/lasi_i82596.c| 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/hw/net/lasi_82596.h b/include/hw/net/lasi_82596.h
index 7b62b04833..6b94726652 100644
--- a/include/hw/net/lasi_82596.h
+++ b/include/hw/net/lasi_82596.h
@@ -14,7 +14,7 @@
 
 #define TYPE_LASI_82596 "lasi_82596"
 typedef struct SysBusI82596State SysBusI82596State;
-DECLARE_INSTANCE_CHECKER(SysBusI82596State, SYSBUS_I82596,
+DECLARE_INSTANCE_CHECKER(SysBusI82596State, LASI_82596,
  TYPE_LASI_82596)
 
 struct SysBusI82596State {
diff --git a/hw/net/lasi_i82596.c b/hw/net/lasi_i82596.c
index 820b63f350..20f85946a1 100644
--- a/hw/net/lasi_i82596.c
+++ b/hw/net/lasi_i82596.c
@@ -109,7 +109,7 @@ static const VMStateDescription vmstate_lasi_82596 = {
 
 static void lasi_82596_realize(DeviceState *dev, Error **errp)
 {
-SysBusI82596State *d = SYSBUS_I82596(dev);
+SysBusI82596State *d = LASI_82596(dev);
 I82596State *s = >state;
 
 memory_region_init_io(>mmio, OBJECT(d), _82596_mem_ops, d,
@@ -128,7 +128,7 @@ SysBusI82596State *lasi_82596_init(MemoryRegion *addr_space,
 
 qemu_check_nic_model(_table[0], TYPE_LASI_82596);
 dev = qdev_new(TYPE_LASI_82596);
-s = SYSBUS_I82596(dev);
+s = LASI_82596(dev);
 s->state.irq = lan_irq;
 qdev_set_nic_properties(dev, _table[0]);
 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), _fatal);
@@ -141,14 +141,14 @@ SysBusI82596State *lasi_82596_init(MemoryRegion 
*addr_space,
 
 static void lasi_82596_reset(DeviceState *dev)
 {
-SysBusI82596State *d = SYSBUS_I82596(dev);
+SysBusI82596State *d = LASI_82596(dev);
 
 i82596_h_reset(>state);
 }
 
 static void lasi_82596_instance_init(Object *obj)
 {
-SysBusI82596State *d = SYSBUS_I82596(obj);
+SysBusI82596State *d = LASI_82596(obj);
 I82596State *s = >state;
 
 device_add_bootindex_property(obj, >conf.bootindex,
-- 
2.26.2




[PATCH 49/63] stm32f205: Rename STM32F2XXTIMER to STM32F2XX_TIMER

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Alistair Francis 
Cc: Peter Maydell 
Cc: qemu-...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/hw/timer/stm32f2xx_timer.h | 2 +-
 hw/timer/stm32f2xx_timer.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/hw/timer/stm32f2xx_timer.h 
b/include/hw/timer/stm32f2xx_timer.h
index 90f40f1746..70ef426afc 100644
--- a/include/hw/timer/stm32f2xx_timer.h
+++ b/include/hw/timer/stm32f2xx_timer.h
@@ -63,7 +63,7 @@
 
 #define TYPE_STM32F2XX_TIMER "stm32f2xx-timer"
 typedef struct STM32F2XXTimerState STM32F2XXTimerState;
-DECLARE_INSTANCE_CHECKER(STM32F2XXTimerState, STM32F2XXTIMER,
+DECLARE_INSTANCE_CHECKER(STM32F2XXTimerState, STM32F2XX_TIMER,
  TYPE_STM32F2XX_TIMER)
 
 struct STM32F2XXTimerState {
diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c
index ba8694dcd3..d880c0b4d5 100644
--- a/hw/timer/stm32f2xx_timer.c
+++ b/hw/timer/stm32f2xx_timer.c
@@ -96,7 +96,7 @@ static void stm32f2xx_timer_set_alarm(STM32F2XXTimerState *s, 
int64_t now)
 
 static void stm32f2xx_timer_reset(DeviceState *dev)
 {
-STM32F2XXTimerState *s = STM32F2XXTIMER(dev);
+STM32F2XXTimerState *s = STM32F2XX_TIMER(dev);
 int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
 s->tim_cr1 = 0;
@@ -306,7 +306,7 @@ static Property stm32f2xx_timer_properties[] = {
 
 static void stm32f2xx_timer_init(Object *obj)
 {
-STM32F2XXTimerState *s = STM32F2XXTIMER(obj);
+STM32F2XXTimerState *s = STM32F2XX_TIMER(obj);
 
 sysbus_init_irq(SYS_BUS_DEVICE(obj), >irq);
 
@@ -317,7 +317,7 @@ static void stm32f2xx_timer_init(Object *obj)
 
 static void stm32f2xx_timer_realize(DeviceState *dev, Error **errp)
 {
-STM32F2XXTimerState *s = STM32F2XXTIMER(dev);
+STM32F2XXTimerState *s = STM32F2XX_TIMER(dev);
 s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, stm32f2xx_timer_interrupt, s);
 }
 
-- 
2.26.2




[PATCH 59/63] kvm: Rename KVM_STATE to KVM_ACCEL

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: Peter Maydell 
Cc: Marcelo Tosatti 
Cc: Richard Henderson 
Cc: Eduardo Habkost 
Cc: Huacai Chen 
Cc: Aleksandar Markovic 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Aleksandar Rikalo 
Cc: David Gibson 
Cc: k...@vger.kernel.org
Cc: qemu-devel@nongnu.org
Cc: qemu-...@nongnu.org
Cc: qemu-...@nongnu.org
---
 include/sysemu/kvm.h |  2 +-
 accel/kvm/kvm-all.c  | 18 +-
 target/arm/kvm.c |  2 +-
 target/i386/kvm.c|  2 +-
 target/mips/kvm.c|  2 +-
 target/ppc/kvm.c |  4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 5bbea53883..89c422e1e7 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -204,7 +204,7 @@ struct KVMState;
 
 #define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm")
 typedef struct KVMState KVMState;
-DECLARE_INSTANCE_CHECKER(KVMState, KVM_STATE,
+DECLARE_INSTANCE_CHECKER(KVMState, KVM_ACCEL,
  TYPE_KVM_ACCEL)
 
 extern KVMState *kvm_state;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 63ef6af9a1..bdf63ca3a3 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -214,7 +214,7 @@ void kvm_resample_fd_notify(int gsi)
 
 int kvm_get_max_memslots(void)
 {
-KVMState *s = KVM_STATE(current_accel());
+KVMState *s = KVM_ACCEL(current_accel());
 
 return s->nr_slots;
 }
@@ -256,7 +256,7 @@ static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml)
 
 bool kvm_has_free_slot(MachineState *ms)
 {
-KVMState *s = KVM_STATE(ms->accelerator);
+KVMState *s = KVM_ACCEL(ms->accelerator);
 bool result;
 KVMMemoryListener *kml = >memory_listener;
 
@@ -1970,7 +1970,7 @@ static int kvm_max_vcpu_id(KVMState *s)
 
 bool kvm_vcpu_id_is_valid(int vcpu_id)
 {
-KVMState *s = KVM_STATE(current_accel());
+KVMState *s = KVM_ACCEL(current_accel());
 return vcpu_id >= 0 && vcpu_id < kvm_max_vcpu_id(s);
 }
 
@@ -1996,7 +1996,7 @@ static int kvm_init(MachineState *ms)
 const char *kvm_type;
 uint64_t dirty_log_manual_caps;
 
-s = KVM_STATE(ms->accelerator);
+s = KVM_ACCEL(ms->accelerator);
 
 /*
  * On systems where the kernel can support different base page
@@ -3084,7 +3084,7 @@ int kvm_get_one_reg(CPUState *cs, uint64_t id, void 
*target)
 static bool kvm_accel_has_memory(MachineState *ms, AddressSpace *as,
  hwaddr start_addr, hwaddr size)
 {
-KVMState *kvm = KVM_STATE(ms->accelerator);
+KVMState *kvm = KVM_ACCEL(ms->accelerator);
 int i;
 
 for (i = 0; i < kvm->nr_as; ++i) {
@@ -3102,7 +3102,7 @@ static void kvm_get_kvm_shadow_mem(Object *obj, Visitor 
*v,
const char *name, void *opaque,
Error **errp)
 {
-KVMState *s = KVM_STATE(obj);
+KVMState *s = KVM_ACCEL(obj);
 int64_t value = s->kvm_shadow_mem;
 
 visit_type_int(v, name, , errp);
@@ -3112,7 +3112,7 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Visitor 
*v,
const char *name, void *opaque,
Error **errp)
 {
-KVMState *s = KVM_STATE(obj);
+KVMState *s = KVM_ACCEL(obj);
 int64_t value;
 
 if (!visit_type_int(v, name, , errp)) {
@@ -3126,7 +3126,7 @@ static void kvm_set_kernel_irqchip(Object *obj, Visitor 
*v,
const char *name, void *opaque,
Error **errp)
 {
-KVMState *s = KVM_STATE(obj);
+KVMState *s = KVM_ACCEL(obj);
 OnOffSplit mode;
 
 if (!visit_type_OnOffSplit(v, name, , errp)) {
@@ -3173,7 +3173,7 @@ bool kvm_kernel_irqchip_split(void)
 
 static void kvm_accel_instance_init(Object *obj)
 {
-KVMState *s = KVM_STATE(obj);
+KVMState *s = KVM_ACCEL(obj);
 
 s->kvm_shadow_mem = -1;
 s->kernel_irqchip_allowed = true;
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 8bb7318378..55583075f3 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -216,7 +216,7 @@ bool kvm_arm_pmu_supported(void)
 
 int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
 {
-KVMState *s = KVM_STATE(ms->accelerator);
+KVMState *s = KVM_ACCEL(ms->accelerator);
 int ret;
 
 ret = kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE);
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 205b68bc0c..2949c5f048 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -155,7 +155,7 @@ bool kvm_allows_irq0_override(void)
 
 static bool kvm_x2apic_api_set_flags(uint64_t flags)
 {
-KVMState *s = KVM_STATE(current_accel());
+KVMState *s = KVM_ACCEL(current_accel());
 
 return !kvm_vm_enable_cap(s, KVM_CAP_X2APIC_API, 0, flags);
 }
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index 72637a1e02..30f9c0349a 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -1277,7 +1277,7 @@ int mips_kvm_type(MachineState 

[PATCH 38/63] ccid-card-passthru: Rename PASSTHRU_CCID_CARD to CCID_PASSTHRU

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/usb/ccid-card-passthru.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index e8e9d37e88..d9f569e201 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -65,7 +65,7 @@ struct PassthruState {
 };
 
 #define TYPE_CCID_PASSTHRU "ccid-card-passthru"
-DECLARE_INSTANCE_CHECKER(PassthruState, PASSTHRU_CCID_CARD,
+DECLARE_INSTANCE_CHECKER(PassthruState, CCID_PASSTHRU,
  TYPE_CCID_PASSTHRU)
 
 /*
@@ -332,7 +332,7 @@ static void ccid_card_vscard_event(void *opaque, 
QEMUChrEvent event)
 static void passthru_apdu_from_guest(
 CCIDCardState *base, const uint8_t *apdu, uint32_t len)
 {
-PassthruState *card = PASSTHRU_CCID_CARD(base);
+PassthruState *card = CCID_PASSTHRU(base);
 
 if (!qemu_chr_fe_backend_connected(>cs)) {
 printf("ccid-passthru: no chardev, discarding apdu length %d\n", len);
@@ -343,7 +343,7 @@ static void passthru_apdu_from_guest(
 
 static const uint8_t *passthru_get_atr(CCIDCardState *base, uint32_t *len)
 {
-PassthruState *card = PASSTHRU_CCID_CARD(base);
+PassthruState *card = CCID_PASSTHRU(base);
 
 *len = card->atr_length;
 return card->atr;
@@ -351,7 +351,7 @@ static const uint8_t *passthru_get_atr(CCIDCardState *base, 
uint32_t *len)
 
 static void passthru_realize(CCIDCardState *base, Error **errp)
 {
-PassthruState *card = PASSTHRU_CCID_CARD(base);
+PassthruState *card = CCID_PASSTHRU(base);
 
 card->vscard_in_pos = 0;
 card->vscard_in_hdr = 0;
-- 
2.26.2




[PATCH 50/63] tpm_crb: Rename CRB to TPM_CRB

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Stefan Berger 
Cc: qemu-devel@nongnu.org
---
 hw/tpm/tpm_crb.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index aa9c00aad3..f4e3f0abbc 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -47,7 +47,7 @@ struct CRBState {
 };
 typedef struct CRBState CRBState;
 
-DECLARE_INSTANCE_CHECKER(CRBState, CRB,
+DECLARE_INSTANCE_CHECKER(CRBState, TPM_CRB,
  TYPE_TPM_CRB)
 
 #define CRB_INTF_TYPE_CRB_ACTIVE 0b1
@@ -86,7 +86,7 @@ enum crb_cancel {
 static uint64_t tpm_crb_mmio_read(void *opaque, hwaddr addr,
   unsigned size)
 {
-CRBState *s = CRB(opaque);
+CRBState *s = TPM_CRB(opaque);
 void *regs = (void *)>regs + (addr & ~3);
 unsigned offset = addr & 3;
 uint32_t val = *(uint32_t *)regs >> (8 * offset);
@@ -113,7 +113,7 @@ static uint8_t tpm_crb_get_active_locty(CRBState *s)
 static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
 {
-CRBState *s = CRB(opaque);
+CRBState *s = TPM_CRB(opaque);
 uint8_t locty =  addr >> 12;
 
 trace_tpm_crb_mmio_write(addr, size, val);
@@ -190,7 +190,7 @@ static const MemoryRegionOps tpm_crb_memory_ops = {
 
 static void tpm_crb_request_completed(TPMIf *ti, int ret)
 {
-CRBState *s = CRB(ti);
+CRBState *s = TPM_CRB(ti);
 
 s->regs[R_CRB_CTRL_START] &= ~CRB_START_INVOKE;
 if (ret != 0) {
@@ -201,7 +201,7 @@ static void tpm_crb_request_completed(TPMIf *ti, int ret)
 
 static enum TPMVersion tpm_crb_get_version(TPMIf *ti)
 {
-CRBState *s = CRB(ti);
+CRBState *s = TPM_CRB(ti);
 
 return tpm_backend_get_tpm_version(s->tpmbe);
 }
@@ -232,7 +232,7 @@ static Property tpm_crb_properties[] = {
 
 static void tpm_crb_reset(void *dev)
 {
-CRBState *s = CRB(dev);
+CRBState *s = TPM_CRB(dev);
 
 if (s->ppi_enabled) {
 tpm_ppi_reset(>ppi);
@@ -281,7 +281,7 @@ static void tpm_crb_reset(void *dev)
 
 static void tpm_crb_realize(DeviceState *dev, Error **errp)
 {
-CRBState *s = CRB(dev);
+CRBState *s = TPM_CRB(dev);
 
 if (!tpm_find()) {
 error_setg(errp, "at most one TPM device is permitted");
-- 
2.26.2




[PATCH 47/63] rs6000_mc: Rename RS6000MC_DEVICE to RS6000MC

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: "Hervé Poussineau" 
Cc: David Gibson 
Cc: qemu-...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/ppc/rs6000_mc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
index 56e96010b8..8611ffa96d 100644
--- a/hw/ppc/rs6000_mc.c
+++ b/hw/ppc/rs6000_mc.c
@@ -30,7 +30,7 @@
 
 #define TYPE_RS6000MC "rs6000-mc"
 typedef struct RS6000MCState RS6000MCState;
-DECLARE_INSTANCE_CHECKER(RS6000MCState, RS6000MC_DEVICE,
+DECLARE_INSTANCE_CHECKER(RS6000MCState, RS6000MC,
  TYPE_RS6000MC)
 
 struct RS6000MCState {
@@ -143,7 +143,7 @@ static const MemoryRegionPortio rs6000mc_port_list[] = {
 
 static void rs6000mc_realize(DeviceState *dev, Error **errp)
 {
-RS6000MCState *s = RS6000MC_DEVICE(dev);
+RS6000MCState *s = RS6000MC(dev);
 int socket = 0;
 unsigned int ram_size = s->ram_size / MiB;
 Error *local_err = NULL;
-- 
2.26.2




[PATCH 37/63] ccid-card-emulated: Rename EMULATED_CCID_CARD to EMULATED_CCID

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/usb/ccid-card-emulated.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 5e4649d367..9803dac5b7 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -47,7 +47,7 @@ do {\
 
 #define TYPE_EMULATED_CCID "ccid-card-emulated"
 typedef struct EmulatedState EmulatedState;
-DECLARE_INSTANCE_CHECKER(EmulatedState, EMULATED_CCID_CARD,
+DECLARE_INSTANCE_CHECKER(EmulatedState, EMULATED_CCID,
  TYPE_EMULATED_CCID)
 
 #define BACKEND_NSS_EMULATED_NAME "nss-emulated"
@@ -138,7 +138,7 @@ struct EmulatedState {
 static void emulated_apdu_from_guest(CCIDCardState *base,
 const uint8_t *apdu, uint32_t len)
 {
-EmulatedState *card = EMULATED_CCID_CARD(base);
+EmulatedState *card = EMULATED_CCID(base);
 EmulEvent *event = (EmulEvent *)g_malloc(sizeof(EmulEvent) + len);
 
 assert(event);
@@ -155,7 +155,7 @@ static void emulated_apdu_from_guest(CCIDCardState *base,
 
 static const uint8_t *emulated_get_atr(CCIDCardState *base, uint32_t *len)
 {
-EmulatedState *card = EMULATED_CCID_CARD(base);
+EmulatedState *card = EMULATED_CCID(base);
 
 *len = card->atr_length;
 return card->atr;
@@ -488,7 +488,7 @@ static uint32_t parse_enumeration(char *str,
 
 static void emulated_realize(CCIDCardState *base, Error **errp)
 {
-EmulatedState *card = EMULATED_CCID_CARD(base);
+EmulatedState *card = EMULATED_CCID(base);
 VCardEmulError ret;
 const EnumTable *ptable;
 
@@ -564,7 +564,7 @@ out1:
 
 static void emulated_unrealize(CCIDCardState *base)
 {
-EmulatedState *card = EMULATED_CCID_CARD(base);
+EmulatedState *card = EMULATED_CCID(base);
 VEvent *vevent = vevent_new(VEVENT_LAST, NULL, NULL);
 
 vevent_queue_vevent(vevent); /* stop vevent thread */
-- 
2.26.2




[PATCH 46/63] renesas: Rename RTMR to RENESAS_TMR

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Yoshinori Sato 
Cc: Magnus Damm 
Cc: qemu-devel@nongnu.org
---
 include/hw/timer/renesas_tmr.h | 6 +++---
 hw/rx/rx62n.c  | 2 +-
 hw/timer/renesas_tmr.c | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/hw/timer/renesas_tmr.h b/include/hw/timer/renesas_tmr.h
index caf7eec0dc..5f2f156160 100644
--- a/include/hw/timer/renesas_tmr.h
+++ b/include/hw/timer/renesas_tmr.h
@@ -13,10 +13,10 @@
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
-#define TYPE_RENESAS_TMR "renesas-tmr"
+#define TYPE_RTMR "renesas-tmr"
 typedef struct RTMRState RTMRState;
-DECLARE_INSTANCE_CHECKER(RTMRState, RTMR,
- TYPE_RENESAS_TMR)
+DECLARE_INSTANCE_CHECKER(RTMRState, RENESAS_TMR,
+ TYPE_RTMR)
 
 enum timer_event {
 cmia = 0,
diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c
index 6eb4eea700..0f564c4dfb 100644
--- a/hw/rx/rx62n.c
+++ b/hw/rx/rx62n.c
@@ -166,7 +166,7 @@ static void register_tmr(RX62NState *s, int unit)
 int i, irqbase;
 
 object_initialize_child(OBJECT(s), "tmr[*]",
->tmr[unit], TYPE_RENESAS_TMR);
+>tmr[unit], TYPE_RTMR);
 tmr = SYS_BUS_DEVICE(>tmr[unit]);
 qdev_prop_set_uint64(DEVICE(tmr), "input-freq", s->pclk_freq_hz);
 sysbus_realize(tmr, _abort);
diff --git a/hw/timer/renesas_tmr.c b/hw/timer/renesas_tmr.c
index 446f2eacdd..53733586c2 100644
--- a/hw/timer/renesas_tmr.c
+++ b/hw/timer/renesas_tmr.c
@@ -396,7 +396,7 @@ static void timer_event1(void *opaque)
 
 static void rtmr_reset(DeviceState *dev)
 {
-RTMRState *tmr = RTMR(dev);
+RTMRState *tmr = RENESAS_TMR(dev);
 tmr->tcr[0]   = tmr->tcr[1]   = 0x00;
 tmr->tcsr[0]  = 0x00;
 tmr->tcsr[1]  = 0x10;
@@ -411,7 +411,7 @@ static void rtmr_reset(DeviceState *dev)
 static void rtmr_init(Object *obj)
 {
 SysBusDevice *d = SYS_BUS_DEVICE(obj);
-RTMRState *tmr = RTMR(obj);
+RTMRState *tmr = RENESAS_TMR(obj);
 int i;
 
 memory_region_init_io(>memory, OBJECT(tmr), _ops,
@@ -462,7 +462,7 @@ static void rtmr_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo rtmr_info = {
-.name = TYPE_RENESAS_TMR,
+.name = TYPE_RTMR,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(RTMRState),
 .instance_init = rtmr_init,
-- 
2.26.2




[PATCH 44/63] renesas: Rename RCMT to RENESAS_CMT

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Yoshinori Sato 
Cc: Magnus Damm 
Cc: qemu-devel@nongnu.org
---
 include/hw/timer/renesas_cmt.h | 2 +-
 hw/timer/renesas_cmt.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/hw/timer/renesas_cmt.h b/include/hw/timer/renesas_cmt.h
index 1c0b65c1d5..89e83df374 100644
--- a/include/hw/timer/renesas_cmt.h
+++ b/include/hw/timer/renesas_cmt.h
@@ -15,7 +15,7 @@
 
 #define TYPE_RENESAS_CMT "renesas-cmt"
 typedef struct RCMTState RCMTState;
-DECLARE_INSTANCE_CHECKER(RCMTState, RCMT,
+DECLARE_INSTANCE_CHECKER(RCMTState, RENESAS_CMT,
  TYPE_RENESAS_CMT)
 
 enum {
diff --git a/hw/timer/renesas_cmt.c b/hw/timer/renesas_cmt.c
index 2e0fd21a36..5700980057 100644
--- a/hw/timer/renesas_cmt.c
+++ b/hw/timer/renesas_cmt.c
@@ -214,7 +214,7 @@ static void timer_event1(void *opaque)
 
 static void rcmt_reset(DeviceState *dev)
 {
-RCMTState *cmt = RCMT(dev);
+RCMTState *cmt = RENESAS_CMT(dev);
 cmt->cmstr = 0;
 cmt->cmcr[0] = cmt->cmcr[1] = 0;
 cmt->cmcnt[0] = cmt->cmcnt[1] = 0;
@@ -224,7 +224,7 @@ static void rcmt_reset(DeviceState *dev)
 static void rcmt_init(Object *obj)
 {
 SysBusDevice *d = SYS_BUS_DEVICE(obj);
-RCMTState *cmt = RCMT(obj);
+RCMTState *cmt = RENESAS_CMT(obj);
 int i;
 
 memory_region_init_io(>memory, OBJECT(cmt), _ops,
-- 
2.26.2




[PATCH 43/63] pvpanic: Rename ISA_PVPANIC_DEVICE to PVPANIC

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: qemu-devel@nongnu.org
---
 hw/misc/pvpanic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 598d5471a4..871be27c19 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -31,7 +31,7 @@
 #define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
 
 typedef struct PVPanicState PVPanicState;
-DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE,
+DECLARE_INSTANCE_CHECKER(PVPanicState, PVPANIC,
  TYPE_PVPANIC)
 
 static void handle_event(int event)
@@ -86,7 +86,7 @@ static const MemoryRegionOps pvpanic_ops = {
 
 static void pvpanic_isa_initfn(Object *obj)
 {
-PVPanicState *s = ISA_PVPANIC_DEVICE(obj);
+PVPanicState *s = PVPANIC(obj);
 
 memory_region_init_io(>io, OBJECT(s), _ops, s, "pvpanic", 1);
 }
@@ -94,7 +94,7 @@ static void pvpanic_isa_initfn(Object *obj)
 static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 {
 ISADevice *d = ISA_DEVICE(dev);
-PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
+PVPanicState *s = PVPANIC(dev);
 FWCfgState *fw_cfg = fw_cfg_find();
 uint16_t *pvpanic_port;
 
-- 
2.26.2




[PATCH 45/63] renesas: Rename RSCI to RENESAS_SCI

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Yoshinori Sato 
Cc: Magnus Damm 
Cc: "Marc-André Lureau" 
Cc: Paolo Bonzini 
Cc: qemu-devel@nongnu.org
---
 include/hw/char/renesas_sci.h |  2 +-
 hw/char/renesas_sci.c | 18 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/hw/char/renesas_sci.h b/include/hw/char/renesas_sci.h
index a4764e3eee..1349d2d003 100644
--- a/include/hw/char/renesas_sci.h
+++ b/include/hw/char/renesas_sci.h
@@ -15,7 +15,7 @@
 
 #define TYPE_RENESAS_SCI "renesas-sci"
 typedef struct RSCIState RSCIState;
-DECLARE_INSTANCE_CHECKER(RSCIState, RSCI,
+DECLARE_INSTANCE_CHECKER(RSCIState, RENESAS_SCI,
  TYPE_RENESAS_SCI)
 
 enum {
diff --git a/hw/char/renesas_sci.c b/hw/char/renesas_sci.c
index 5d7c6e6523..286fd28a39 100644
--- a/hw/char/renesas_sci.c
+++ b/hw/char/renesas_sci.c
@@ -70,7 +70,7 @@ REG8(SEMR, 7)
 
 static int can_receive(void *opaque)
 {
-RSCIState *sci = RSCI(opaque);
+RSCIState *sci = RENESAS_SCI(opaque);
 if (sci->rx_next > qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)) {
 return 0;
 } else {
@@ -80,7 +80,7 @@ static int can_receive(void *opaque)
 
 static void receive(void *opaque, const uint8_t *buf, int size)
 {
-RSCIState *sci = RSCI(opaque);
+RSCIState *sci = RENESAS_SCI(opaque);
 sci->rx_next = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + sci->trtime;
 if (FIELD_EX8(sci->ssr, SSR, RDRF) || size > 1) {
 sci->ssr = FIELD_DP8(sci->ssr, SSR, ORER, 1);
@@ -112,7 +112,7 @@ static void send_byte(RSCIState *sci)
 
 static void txend(void *opaque)
 {
-RSCIState *sci = RSCI(opaque);
+RSCIState *sci = RENESAS_SCI(opaque);
 if (!FIELD_EX8(sci->ssr, SSR, TDRE)) {
 send_byte(sci);
 } else {
@@ -143,7 +143,7 @@ static bool sci_is_tr_enabled(RSCIState *sci)
 
 static void sci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 {
-RSCIState *sci = RSCI(opaque);
+RSCIState *sci = RENESAS_SCI(opaque);
 
 switch (offset) {
 case A_SMR:
@@ -208,7 +208,7 @@ static void sci_write(void *opaque, hwaddr offset, uint64_t 
val, unsigned size)
 
 static uint64_t sci_read(void *opaque, hwaddr offset, unsigned size)
 {
-RSCIState *sci = RSCI(opaque);
+RSCIState *sci = RENESAS_SCI(opaque);
 
 switch (offset) {
 case A_SMR:
@@ -246,7 +246,7 @@ static const MemoryRegionOps sci_ops = {
 
 static void rsci_reset(DeviceState *dev)
 {
-RSCIState *sci = RSCI(dev);
+RSCIState *sci = RENESAS_SCI(dev);
 sci->smr = sci->scr = 0x00;
 sci->brr = 0xff;
 sci->tdr = 0xff;
@@ -259,7 +259,7 @@ static void rsci_reset(DeviceState *dev)
 
 static void sci_event(void *opaque, QEMUChrEvent event)
 {
-RSCIState *sci = RSCI(opaque);
+RSCIState *sci = RENESAS_SCI(opaque);
 if (event == CHR_EVENT_BREAK) {
 sci->ssr = FIELD_DP8(sci->ssr, SSR, FER, 1);
 if (FIELD_EX8(sci->scr, SCR, RIE)) {
@@ -270,7 +270,7 @@ static void sci_event(void *opaque, QEMUChrEvent event)
 
 static void rsci_realize(DeviceState *dev, Error **errp)
 {
-RSCIState *sci = RSCI(dev);
+RSCIState *sci = RENESAS_SCI(dev);
 
 if (sci->input_freq == 0) {
 qemu_log_mask(LOG_GUEST_ERROR,
@@ -284,7 +284,7 @@ static void rsci_realize(DeviceState *dev, Error **errp)
 static void rsci_init(Object *obj)
 {
 SysBusDevice *d = SYS_BUS_DEVICE(obj);
-RSCIState *sci = RSCI(obj);
+RSCIState *sci = RENESAS_SCI(obj);
 int i;
 
 memory_region_init_io(>memory, OBJECT(sci), _ops,
-- 
2.26.2




[PATCH 36/63] can: Rename PCM3680i_PCI_DEV to PCM3680_PCI

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 hw/net/can/can_pcm3680_pci.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/net/can/can_pcm3680_pci.c b/hw/net/can/can_pcm3680_pci.c
index 530cd04a5d..cb9db3c322 100644
--- a/hw/net/can/can_pcm3680_pci.c
+++ b/hw/net/can/can_pcm3680_pci.c
@@ -44,7 +44,7 @@
 #define TYPE_PCM3680_PCI "pcm3680_pci"
 
 typedef struct Pcm3680iPCIState Pcm3680iPCIState;
-DECLARE_INSTANCE_CHECKER(Pcm3680iPCIState, PCM3680i_PCI_DEV,
+DECLARE_INSTANCE_CHECKER(Pcm3680iPCIState, PCM3680_PCI,
  TYPE_PCM3680_PCI)
 
 /* the PCI device and vendor IDs */
@@ -76,7 +76,7 @@ struct Pcm3680iPCIState {
 
 static void pcm3680i_pci_reset(DeviceState *dev)
 {
-Pcm3680iPCIState *d = PCM3680i_PCI_DEV(dev);
+Pcm3680iPCIState *d = PCM3680_PCI(dev);
 int i;
 
 for (i = 0; i < PCM3680i_PCI_SJA_COUNT; i++) {
@@ -156,7 +156,7 @@ static const MemoryRegionOps pcm3680i_pci_sja2_io_ops = {
 
 static void pcm3680i_pci_realize(PCIDevice *pci_dev, Error **errp)
 {
-Pcm3680iPCIState *d = PCM3680i_PCI_DEV(pci_dev);
+Pcm3680iPCIState *d = PCM3680_PCI(pci_dev);
 uint8_t *pci_conf;
 int i;
 
@@ -190,7 +190,7 @@ static void pcm3680i_pci_realize(PCIDevice *pci_dev, Error 
**errp)
 
 static void pcm3680i_pci_exit(PCIDevice *pci_dev)
 {
-Pcm3680iPCIState *d = PCM3680i_PCI_DEV(pci_dev);
+Pcm3680iPCIState *d = PCM3680_PCI(pci_dev);
 int i;
 
 for (i = 0; i < PCM3680i_PCI_SJA_COUNT; i++) {
@@ -217,7 +217,7 @@ static const VMStateDescription vmstate_pcm3680i_pci = {
 
 static void pcm3680i_pci_instance_init(Object *obj)
 {
-Pcm3680iPCIState *d = PCM3680i_PCI_DEV(obj);
+Pcm3680iPCIState *d = PCM3680_PCI(obj);
 
 object_property_add_link(obj, "canbus0", TYPE_CAN_BUS,
  (Object **)>canbus[0],
-- 
2.26.2




[PATCH 39/63] esp: Rename ESP_STATE to ESP

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Mark Cave-Ayland 
Cc: Laurent Vivier 
Cc: "Hervé Poussineau" 
Cc: Aleksandar Rikalo 
Cc: Aleksandar Markovic 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: Artyom Tarasenko 
Cc: qemu-devel@nongnu.org
---
 include/hw/scsi/esp.h | 2 +-
 hw/dma/sparc32_dma.c  | 2 +-
 hw/m68k/q800.c| 2 +-
 hw/mips/jazz.c| 2 +-
 hw/scsi/esp.c | 6 +++---
 hw/sparc/sun4m.c  | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h
index f281625dd5..20800dbf5b 100644
--- a/include/hw/scsi/esp.h
+++ b/include/hw/scsi/esp.h
@@ -67,7 +67,7 @@ struct ESPState {
 
 #define TYPE_ESP "esp"
 typedef struct SysBusESPState SysBusESPState;
-DECLARE_INSTANCE_CHECKER(SysBusESPState, ESP_STATE,
+DECLARE_INSTANCE_CHECKER(SysBusESPState, ESP,
  TYPE_ESP)
 
 struct SysBusESPState {
diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
index bcd1626fbd..d20a5bc065 100644
--- a/hw/dma/sparc32_dma.c
+++ b/hw/dma/sparc32_dma.c
@@ -303,7 +303,7 @@ static void sparc32_espdma_device_realize(DeviceState *dev, 
Error **errp)
 
 d = qdev_new(TYPE_ESP);
 object_property_add_child(OBJECT(dev), "esp", OBJECT(d));
-sysbus = ESP_STATE(d);
+sysbus = ESP(d);
 esp = >esp;
 esp->dma_memory_read = espdma_memory_read;
 esp->dma_memory_write = espdma_memory_write;
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 1ca482ad81..ce4b47c3e3 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -290,7 +290,7 @@ static void q800_init(MachineState *machine)
 /* SCSI */
 
 dev = qdev_new(TYPE_ESP);
-sysbus_esp = ESP_STATE(dev);
+sysbus_esp = ESP(dev);
 esp = _esp->esp;
 esp->dma_memory_read = NULL;
 esp->dma_memory_write = NULL;
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 82a6e3220e..47723093b6 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -309,7 +309,7 @@ static void mips_jazz_init(MachineState *machine,
 
 /* SCSI adapter */
 dev = qdev_new(TYPE_ESP);
-sysbus_esp = ESP_STATE(dev);
+sysbus_esp = ESP(dev);
 esp = _esp->esp;
 esp->dma_memory_read = rc4030_dma_read;
 esp->dma_memory_write = rc4030_dma_write;
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 405f8b7cbc..b84e0fe33e 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -929,7 +929,7 @@ static const struct SCSIBusInfo esp_scsi_info = {
 
 static void sysbus_esp_gpio_demux(void *opaque, int irq, int level)
 {
-SysBusESPState *sysbus = ESP_STATE(opaque);
+SysBusESPState *sysbus = ESP(opaque);
 ESPState *s = >esp;
 
 switch (irq) {
@@ -945,7 +945,7 @@ static void sysbus_esp_gpio_demux(void *opaque, int irq, 
int level)
 static void sysbus_esp_realize(DeviceState *dev, Error **errp)
 {
 SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
-SysBusESPState *sysbus = ESP_STATE(dev);
+SysBusESPState *sysbus = ESP(dev);
 ESPState *s = >esp;
 
 sysbus_init_irq(sbd, >irq);
@@ -967,7 +967,7 @@ static void sysbus_esp_realize(DeviceState *dev, Error 
**errp)
 
 static void sysbus_esp_hard_reset(DeviceState *dev)
 {
-SysBusESPState *sysbus = ESP_STATE(dev);
+SysBusESPState *sysbus = ESP(dev);
 esp_hard_reset(>esp);
 }
 
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 3410d8db6c..3ee7ef4590 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -345,7 +345,7 @@ static void *sparc32_dma_init(hwaddr dma_base,
OBJECT(dma), "espdma"));
 sysbus_connect_irq(SYS_BUS_DEVICE(espdma), 0, espdma_irq);
 
-esp = ESP_STATE(object_resolve_path_component(OBJECT(espdma), "esp"));
+esp = ESP(object_resolve_path_component(OBJECT(espdma), "esp"));
 sysbus_mmio_map(SYS_BUS_DEVICE(esp), 0, esp_base);
 scsi_bus_legacy_handle_cmdline(>esp.bus);
 
-- 
2.26.2




[PATCH 31/63] virtio-console: Rename TYPE_VIRTIO_CONSOLE_SERIAL_PORT to TYPE_VIRTIO_CONSOLE

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Laurent Vivier 
Cc: Amit Shah 
Cc: "Michael S. Tsirkin" 
Cc: "Marc-André Lureau" 
Cc: Paolo Bonzini 
Cc: qemu-devel@nongnu.org
---
 hw/char/virtio-console.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index bc752cf90f..cf4c0a0a95 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -21,10 +21,10 @@
 #include "qapi/qapi-events-char.h"
 #include "qom/object.h"
 
-#define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport"
+#define TYPE_VIRTIO_CONSOLE "virtserialport"
 typedef struct VirtConsole VirtConsole;
 DECLARE_INSTANCE_CHECKER(VirtConsole, VIRTIO_CONSOLE,
- TYPE_VIRTIO_CONSOLE_SERIAL_PORT)
+ TYPE_VIRTIO_CONSOLE)
 
 struct VirtConsole {
 VirtIOSerialPort parent_obj;
@@ -269,7 +269,7 @@ static void virtconsole_class_init(ObjectClass *klass, void 
*data)
 
 static const TypeInfo virtconsole_info = {
 .name  = "virtconsole",
-.parent= TYPE_VIRTIO_CONSOLE_SERIAL_PORT,
+.parent= TYPE_VIRTIO_CONSOLE,
 .class_init= virtconsole_class_init,
 };
 
@@ -293,7 +293,7 @@ static void virtserialport_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo virtserialport_info = {
-.name  = TYPE_VIRTIO_CONSOLE_SERIAL_PORT,
+.name  = TYPE_VIRTIO_CONSOLE,
 .parent= TYPE_VIRTIO_SERIAL_PORT,
 .instance_size = sizeof(VirtConsole),
 .class_init= virtserialport_class_init,
-- 
2.26.2




[PATCH 41/63] lance: Rename SYSBUS_PCNET to LANCE

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Jason Wang 
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-devel@nongnu.org
---
 include/hw/net/lance.h | 2 +-
 hw/net/lance.c | 6 +++---
 hw/sparc/sun4m.c   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/hw/net/lance.h b/include/hw/net/lance.h
index f645d6af67..a0434f1254 100644
--- a/include/hw/net/lance.h
+++ b/include/hw/net/lance.h
@@ -36,7 +36,7 @@
 
 #define TYPE_LANCE "lance"
 typedef struct SysBusPCNetState SysBusPCNetState;
-DECLARE_INSTANCE_CHECKER(SysBusPCNetState, SYSBUS_PCNET,
+DECLARE_INSTANCE_CHECKER(SysBusPCNetState, LANCE,
  TYPE_LANCE)
 
 struct SysBusPCNetState {
diff --git a/hw/net/lance.c b/hw/net/lance.c
index 4c5f01baad..47ab7e1847 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -103,7 +103,7 @@ static const VMStateDescription vmstate_lance = {
 static void lance_realize(DeviceState *dev, Error **errp)
 {
 SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
-SysBusPCNetState *d = SYSBUS_PCNET(dev);
+SysBusPCNetState *d = LANCE(dev);
 PCNetState *s = >state;
 
 memory_region_init_io(>mmio, OBJECT(d), _mem_ops, d,
@@ -122,14 +122,14 @@ static void lance_realize(DeviceState *dev, Error **errp)
 
 static void lance_reset(DeviceState *dev)
 {
-SysBusPCNetState *d = SYSBUS_PCNET(dev);
+SysBusPCNetState *d = LANCE(dev);
 
 pcnet_h_reset(>state);
 }
 
 static void lance_instance_init(Object *obj)
 {
-SysBusPCNetState *d = SYSBUS_PCNET(obj);
+SysBusPCNetState *d = LANCE(obj);
 PCNetState *s = >state;
 
 device_add_bootindex_property(obj, >conf.bootindex,
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 3ee7ef4590..192cb87658 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -353,7 +353,7 @@ static void *sparc32_dma_init(hwaddr dma_base,
  OBJECT(dma), "ledma"));
 sysbus_connect_irq(SYS_BUS_DEVICE(ledma), 0, ledma_irq);
 
-lance = SYSBUS_PCNET(object_resolve_path_component(
+lance = LANCE(object_resolve_path_component(
  OBJECT(ledma), "lance"));
 sysbus_mmio_map(SYS_BUS_DEVICE(lance), 0, le_base);
 
-- 
2.26.2




[PATCH 35/63] can: Rename MIOe3680_PCI_DEV to MIOE3680_PCI

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 hw/net/can/can_mioe3680_pci.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/net/can/can_mioe3680_pci.c b/hw/net/can/can_mioe3680_pci.c
index b20e5451bf..9aaa9503c4 100644
--- a/hw/net/can/can_mioe3680_pci.c
+++ b/hw/net/can/can_mioe3680_pci.c
@@ -44,7 +44,7 @@
 #define TYPE_MIOE3680_PCI "mioe3680_pci"
 
 typedef struct Mioe3680PCIState Mioe3680PCIState;
-DECLARE_INSTANCE_CHECKER(Mioe3680PCIState, MIOe3680_PCI_DEV,
+DECLARE_INSTANCE_CHECKER(Mioe3680PCIState, MIOE3680_PCI,
  TYPE_MIOE3680_PCI)
 
 /* the PCI device and vendor IDs */
@@ -76,7 +76,7 @@ struct Mioe3680PCIState {
 
 static void mioe3680_pci_reset(DeviceState *dev)
 {
-Mioe3680PCIState *d = MIOe3680_PCI_DEV(dev);
+Mioe3680PCIState *d = MIOE3680_PCI(dev);
 int i;
 
 for (i = 0 ; i < MIOe3680_PCI_SJA_COUNT; i++) {
@@ -156,7 +156,7 @@ static const MemoryRegionOps mioe3680_pci_sja2_io_ops = {
 
 static void mioe3680_pci_realize(PCIDevice *pci_dev, Error **errp)
 {
-Mioe3680PCIState *d = MIOe3680_PCI_DEV(pci_dev);
+Mioe3680PCIState *d = MIOE3680_PCI(pci_dev);
 uint8_t *pci_conf;
 int i;
 
@@ -189,7 +189,7 @@ static void mioe3680_pci_realize(PCIDevice *pci_dev, Error 
**errp)
 
 static void mioe3680_pci_exit(PCIDevice *pci_dev)
 {
-Mioe3680PCIState *d = MIOe3680_PCI_DEV(pci_dev);
+Mioe3680PCIState *d = MIOE3680_PCI(pci_dev);
 int i;
 
 for (i = 0 ; i < MIOe3680_PCI_SJA_COUNT; i++) {
@@ -216,7 +216,7 @@ static const VMStateDescription vmstate_mioe3680_pci = {
 
 static void mioe3680_pci_instance_init(Object *obj)
 {
-Mioe3680PCIState *d = MIOe3680_PCI_DEV(obj);
+Mioe3680PCIState *d = MIOE3680_PCI(obj);
 
 object_property_add_link(obj, "canbus0", TYPE_CAN_BUS,
  (Object **)>canbus[0],
-- 
2.26.2




[PATCH 32/63] ahci: Rename ICH_AHCI to ICH9_AHCI

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: John Snow 
Cc: qemu-bl...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/hw/ide/ahci.h | 2 +-
 hw/ide/ahci.c | 4 ++--
 hw/ide/ich.c  | 8 
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/hw/ide/ahci.h b/include/hw/ide/ahci.h
index 4cf6813d80..da3cddcc65 100644
--- a/include/hw/ide/ahci.h
+++ b/include/hw/ide/ahci.h
@@ -54,7 +54,7 @@ typedef struct AHCIState {
 typedef struct AHCIPCIState AHCIPCIState;
 
 #define TYPE_ICH9_AHCI "ich9-ahci"
-DECLARE_INSTANCE_CHECKER(AHCIPCIState, ICH_AHCI,
+DECLARE_INSTANCE_CHECKER(AHCIPCIState, ICH9_AHCI,
  TYPE_ICH9_AHCI)
 
 int32_t ahci_get_num_ports(PCIDevice *dev);
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index b696c6291a..ee1d47ff75 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1819,7 +1819,7 @@ type_init(sysbus_ahci_register_types)
 
 int32_t ahci_get_num_ports(PCIDevice *dev)
 {
-AHCIPCIState *d = ICH_AHCI(dev);
+AHCIPCIState *d = ICH9_AHCI(dev);
 AHCIState *ahci = >ahci;
 
 return ahci->ports;
@@ -1827,7 +1827,7 @@ int32_t ahci_get_num_ports(PCIDevice *dev)
 
 void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd)
 {
-AHCIPCIState *d = ICH_AHCI(dev);
+AHCIPCIState *d = ICH9_AHCI(dev);
 AHCIState *ahci = >ahci;
 int i;
 
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index eff3188fff..51cd2f38b7 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -91,14 +91,14 @@ static const VMStateDescription vmstate_ich9_ahci = {
 
 static void pci_ich9_reset(DeviceState *dev)
 {
-AHCIPCIState *d = ICH_AHCI(dev);
+AHCIPCIState *d = ICH9_AHCI(dev);
 
 ahci_reset(>ahci);
 }
 
 static void pci_ich9_ahci_init(Object *obj)
 {
-struct AHCIPCIState *d = ICH_AHCI(obj);
+struct AHCIPCIState *d = ICH9_AHCI(obj);
 
 ahci_init(>ahci, DEVICE(obj));
 }
@@ -108,7 +108,7 @@ static void pci_ich9_ahci_realize(PCIDevice *dev, Error 
**errp)
 struct AHCIPCIState *d;
 int sata_cap_offset;
 uint8_t *sata_cap;
-d = ICH_AHCI(dev);
+d = ICH9_AHCI(dev);
 int ret;
 
 ahci_realize(>ahci, DEVICE(dev), pci_get_address_space(dev), 6);
@@ -154,7 +154,7 @@ static void pci_ich9_ahci_realize(PCIDevice *dev, Error 
**errp)
 static void pci_ich9_uninit(PCIDevice *dev)
 {
 struct AHCIPCIState *d;
-d = ICH_AHCI(dev);
+d = ICH9_AHCI(dev);
 
 msi_uninit(dev);
 ahci_uninit(>ahci);
-- 
2.26.2




[PATCH 29/63] versatile: Rename TYPE_VERSATILE_PCI_HOST to TYPE_PCI_VPB_HOST

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Peter Maydell 
Cc: qemu-...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/pci-host/versatile.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
index 3553277f94..7b6a754b8b 100644
--- a/hw/pci-host/versatile.c
+++ b/hw/pci-host/versatile.c
@@ -161,9 +161,9 @@ static const VMStateDescription pci_vpb_vmstate = {
 DECLARE_INSTANCE_CHECKER(PCIVPBState, PCI_VPB,
  TYPE_VERSATILE_PCI)
 
-#define TYPE_VERSATILE_PCI_HOST "versatile_pci_host"
+#define TYPE_PCI_VPB_HOST "versatile_pci_host"
 DECLARE_INSTANCE_CHECKER(PCIDevice, PCI_VPB_HOST,
- TYPE_VERSATILE_PCI_HOST)
+ TYPE_PCI_VPB_HOST)
 
 typedef enum {
 PCI_IMAP0 = 0x0,
@@ -410,7 +410,7 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp)
  PCI_DEVFN(11, 0), TYPE_PCI_BUS);
 h->bus = >pci_bus;
 
-object_initialize(>pci_dev, sizeof(s->pci_dev), 
TYPE_VERSATILE_PCI_HOST);
+object_initialize(>pci_dev, sizeof(s->pci_dev), TYPE_PCI_VPB_HOST);
 
 for (i = 0; i < 4; i++) {
 sysbus_init_irq(sbd, >irq[i]);
@@ -487,7 +487,7 @@ static void versatile_pci_host_class_init(ObjectClass 
*klass, void *data)
 }
 
 static const TypeInfo versatile_pci_host_info = {
-.name  = TYPE_VERSATILE_PCI_HOST,
+.name  = TYPE_PCI_VPB_HOST,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PCIDevice),
 .class_init= versatile_pci_host_class_init,
-- 
2.26.2




[PATCH 40/63] filter-rewriter: Rename FILTER_COLO_REWRITER to FILTER_REWRITER

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Zhang Chen 
Cc: Li Zhijian 
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 net/filter-rewriter.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index 113e293207..44f6021dd8 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -25,7 +25,7 @@
 
 #define TYPE_FILTER_REWRITER "filter-rewriter"
 typedef struct RewriterState RewriterState;
-DECLARE_INSTANCE_CHECKER(RewriterState, FILTER_COLO_REWRITER,
+DECLARE_INSTANCE_CHECKER(RewriterState, FILTER_REWRITER,
  TYPE_FILTER_REWRITER)
 
 #define FAILOVER_MODE_ON  true
@@ -47,7 +47,7 @@ static void filter_rewriter_failover_mode(RewriterState *s)
 
 static void filter_rewriter_flush(NetFilterState *nf)
 {
-RewriterState *s = FILTER_COLO_REWRITER(nf);
+RewriterState *s = FILTER_REWRITER(nf);
 
 if (!qemu_net_queue_flush(s->incoming_queue)) {
 /* Unable to empty the queue, purge remaining packets */
@@ -252,7 +252,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
  int iovcnt,
  NetPacketSent *sent_cb)
 {
-RewriterState *s = FILTER_COLO_REWRITER(nf);
+RewriterState *s = FILTER_REWRITER(nf);
 Connection *conn;
 ConnectionKey key;
 Packet *pkt;
@@ -350,7 +350,7 @@ static gboolean offset_is_nonzero(gpointer key,
 static void colo_rewriter_handle_event(NetFilterState *nf, int event,
Error **errp)
 {
-RewriterState *rs = FILTER_COLO_REWRITER(nf);
+RewriterState *rs = FILTER_REWRITER(nf);
 
 switch (event) {
 case COLO_EVENT_CHECKPOINT:
@@ -370,7 +370,7 @@ static void colo_rewriter_handle_event(NetFilterState *nf, 
int event,
 
 static void colo_rewriter_cleanup(NetFilterState *nf)
 {
-RewriterState *s = FILTER_COLO_REWRITER(nf);
+RewriterState *s = FILTER_REWRITER(nf);
 
 /* flush packets */
 if (s->incoming_queue) {
@@ -381,7 +381,7 @@ static void colo_rewriter_cleanup(NetFilterState *nf)
 
 static void colo_rewriter_setup(NetFilterState *nf, Error **errp)
 {
-RewriterState *s = FILTER_COLO_REWRITER(nf);
+RewriterState *s = FILTER_REWRITER(nf);
 
 s->connection_track_table = g_hash_table_new_full(connection_key_hash,
   connection_key_equal,
@@ -392,7 +392,7 @@ static void colo_rewriter_setup(NetFilterState *nf, Error 
**errp)
 
 static bool filter_rewriter_get_vnet_hdr(Object *obj, Error **errp)
 {
-RewriterState *s = FILTER_COLO_REWRITER(obj);
+RewriterState *s = FILTER_REWRITER(obj);
 
 return s->vnet_hdr;
 }
@@ -401,14 +401,14 @@ static void filter_rewriter_set_vnet_hdr(Object *obj,
  bool value,
  Error **errp)
 {
-RewriterState *s = FILTER_COLO_REWRITER(obj);
+RewriterState *s = FILTER_REWRITER(obj);
 
 s->vnet_hdr = value;
 }
 
 static void filter_rewriter_init(Object *obj)
 {
-RewriterState *s = FILTER_COLO_REWRITER(obj);
+RewriterState *s = FILTER_REWRITER(obj);
 
 s->vnet_hdr = false;
 s->failover_mode = FAILOVER_MODE_OFF;
-- 
2.26.2




[PATCH 34/63] can: Rename KVASER_PCI_DEV to KVASER_PCI

2020-09-02 Thread Eduardo Habkost
Make the type checking macro name consistent with the TYPE_*
constant.

Signed-off-by: Eduardo Habkost 
---
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 hw/net/can/can_kvaser_pci.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/net/can/can_kvaser_pci.c b/hw/net/can/can_kvaser_pci.c
index 12d4f8df33..2143ed83f3 100644
--- a/hw/net/can/can_kvaser_pci.c
+++ b/hw/net/can/can_kvaser_pci.c
@@ -48,7 +48,7 @@
 #define TYPE_KVASER_PCI "kvaser_pci"
 
 typedef struct KvaserPCIState KvaserPCIState;
-DECLARE_INSTANCE_CHECKER(KvaserPCIState, KVASER_PCI_DEV,
+DECLARE_INSTANCE_CHECKER(KvaserPCIState, KVASER_PCI,
  TYPE_KVASER_PCI)
 
 #ifndef KVASER_PCI_VENDOR_ID1
@@ -109,7 +109,7 @@ static void kvaser_pci_irq_handler(void *opaque, int 
irq_num, int level)
 
 static void kvaser_pci_reset(DeviceState *dev)
 {
-KvaserPCIState *d = KVASER_PCI_DEV(dev);
+KvaserPCIState *d = KVASER_PCI(dev);
 CanSJA1000State *s = >sja_state;
 
 can_sja_hardware_reset(s);
@@ -221,7 +221,7 @@ static const MemoryRegionOps kvaser_pci_xilinx_io_ops = {
 
 static void kvaser_pci_realize(PCIDevice *pci_dev, Error **errp)
 {
-KvaserPCIState *d = KVASER_PCI_DEV(pci_dev);
+KvaserPCIState *d = KVASER_PCI(pci_dev);
 CanSJA1000State *s = >sja_state;
 uint8_t *pci_conf;
 
@@ -254,7 +254,7 @@ static void kvaser_pci_realize(PCIDevice *pci_dev, Error 
**errp)
 
 static void kvaser_pci_exit(PCIDevice *pci_dev)
 {
-KvaserPCIState *d = KVASER_PCI_DEV(pci_dev);
+KvaserPCIState *d = KVASER_PCI(pci_dev);
 CanSJA1000State *s = >sja_state;
 
 can_sja_disconnect(s);
@@ -279,7 +279,7 @@ static const VMStateDescription vmstate_kvaser_pci = {
 
 static void kvaser_pci_instance_init(Object *obj)
 {
-KvaserPCIState *d = KVASER_PCI_DEV(obj);
+KvaserPCIState *d = KVASER_PCI(obj);
 
 object_property_add_link(obj, "canbus", TYPE_CAN_BUS,
  (Object **)>canbus,
-- 
2.26.2




[PATCH 33/63] net/can: Rename TYPE_CAN_CPI constants

2020-09-02 Thread Eduardo Habkost
Rename macros to names that are unique in the source tree, to
reduce confusion and make automated conversion of the code
easier.

Signed-off-by: Eduardo Habkost 
---
Cc: Jason Wang 
Cc: qemu-devel@nongnu.org
---
 hw/net/can/can_kvaser_pci.c   | 6 +++---
 hw/net/can/can_mioe3680_pci.c | 6 +++---
 hw/net/can/can_pcm3680_pci.c  | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/net/can/can_kvaser_pci.c b/hw/net/can/can_kvaser_pci.c
index 168b3a620d..12d4f8df33 100644
--- a/hw/net/can/can_kvaser_pci.c
+++ b/hw/net/can/can_kvaser_pci.c
@@ -45,11 +45,11 @@
 #include "can_sja1000.h"
 #include "qom/object.h"
 
-#define TYPE_CAN_PCI_DEV "kvaser_pci"
+#define TYPE_KVASER_PCI "kvaser_pci"
 
 typedef struct KvaserPCIState KvaserPCIState;
 DECLARE_INSTANCE_CHECKER(KvaserPCIState, KVASER_PCI_DEV,
- TYPE_CAN_PCI_DEV)
+ TYPE_KVASER_PCI)
 
 #ifndef KVASER_PCI_VENDOR_ID1
 #define KVASER_PCI_VENDOR_ID1 0x10e8/* the PCI device and vendor IDs */
@@ -305,7 +305,7 @@ static void kvaser_pci_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo kvaser_pci_info = {
-.name  = TYPE_CAN_PCI_DEV,
+.name  = TYPE_KVASER_PCI,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(KvaserPCIState),
 .class_init= kvaser_pci_class_init,
diff --git a/hw/net/can/can_mioe3680_pci.c b/hw/net/can/can_mioe3680_pci.c
index 7a79e2605a..b20e5451bf 100644
--- a/hw/net/can/can_mioe3680_pci.c
+++ b/hw/net/can/can_mioe3680_pci.c
@@ -41,11 +41,11 @@
 #include "can_sja1000.h"
 #include "qom/object.h"
 
-#define TYPE_CAN_PCI_DEV "mioe3680_pci"
+#define TYPE_MIOE3680_PCI "mioe3680_pci"
 
 typedef struct Mioe3680PCIState Mioe3680PCIState;
 DECLARE_INSTANCE_CHECKER(Mioe3680PCIState, MIOe3680_PCI_DEV,
- TYPE_CAN_PCI_DEV)
+ TYPE_MIOE3680_PCI)
 
 /* the PCI device and vendor IDs */
 #ifndef MIOe3680_PCI_VENDOR_ID1
@@ -248,7 +248,7 @@ static void mioe3680_pci_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo mioe3680_pci_info = {
-.name  = TYPE_CAN_PCI_DEV,
+.name  = TYPE_MIOE3680_PCI,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(Mioe3680PCIState),
 .class_init= mioe3680_pci_class_init,
diff --git a/hw/net/can/can_pcm3680_pci.c b/hw/net/can/can_pcm3680_pci.c
index 8ef4e74af0..530cd04a5d 100644
--- a/hw/net/can/can_pcm3680_pci.c
+++ b/hw/net/can/can_pcm3680_pci.c
@@ -41,11 +41,11 @@
 #include "can_sja1000.h"
 #include "qom/object.h"
 
-#define TYPE_CAN_PCI_DEV "pcm3680_pci"
+#define TYPE_PCM3680_PCI "pcm3680_pci"
 
 typedef struct Pcm3680iPCIState Pcm3680iPCIState;
 DECLARE_INSTANCE_CHECKER(Pcm3680iPCIState, PCM3680i_PCI_DEV,
- TYPE_CAN_PCI_DEV)
+ TYPE_PCM3680_PCI)
 
 /* the PCI device and vendor IDs */
 #ifndef PCM3680i_PCI_VENDOR_ID1
@@ -249,7 +249,7 @@ static void pcm3680i_pci_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo pcm3680i_pci_info = {
-.name  = TYPE_CAN_PCI_DEV,
+.name  = TYPE_PCM3680_PCI,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(Pcm3680iPCIState),
 .class_init= pcm3680i_pci_class_init,
-- 
2.26.2




[PATCH 26/63] sun4m: Rename TYPE_SUN4M_MEMORY to TYPE_SUN4M_RAM

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-devel@nongnu.org
---
 hw/sparc/sun4m.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 5ed922d436..3410d8db6c 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -779,10 +779,10 @@ static const TypeInfo prom_info = {
 .class_init= prom_class_init,
 };
 
-#define TYPE_SUN4M_MEMORY "memory"
+#define TYPE_SUN4M_RAM "memory"
 typedef struct RamDevice RamDevice;
 DECLARE_INSTANCE_CHECKER(RamDevice, SUN4M_RAM,
- TYPE_SUN4M_MEMORY)
+ TYPE_SUN4M_RAM)
 
 struct RamDevice {
 SysBusDevice parent_obj;
@@ -817,7 +817,7 @@ static void ram_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo ram_info = {
-.name  = TYPE_SUN4M_MEMORY,
+.name  = TYPE_SUN4M_RAM,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(RamDevice),
 .instance_init = ram_initfn,
-- 
2.26.2




[PATCH 27/63] sun4u: Rename TYPE_SUN4U_MEMORY to TYPE_SUN4U_RAM

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Mark Cave-Ayland 
Cc: Artyom Tarasenko 
Cc: qemu-devel@nongnu.org
---
 hw/sparc64/sun4u.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 67985414e2..fe0d84bf6c 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -493,10 +493,10 @@ static const TypeInfo prom_info = {
 };
 
 
-#define TYPE_SUN4U_MEMORY "memory"
+#define TYPE_SUN4U_RAM "memory"
 typedef struct RamDevice RamDevice;
 DECLARE_INSTANCE_CHECKER(RamDevice, SUN4U_RAM,
- TYPE_SUN4U_MEMORY)
+ TYPE_SUN4U_RAM)
 
 struct RamDevice {
 SysBusDevice parent_obj;
@@ -524,7 +524,7 @@ static void ram_init(hwaddr addr, ram_addr_t RAM_size)
 RamDevice *d;
 
 /* allocate RAM */
-dev = qdev_new(TYPE_SUN4U_MEMORY);
+dev = qdev_new(TYPE_SUN4U_RAM);
 s = SYS_BUS_DEVICE(dev);
 
 d = SUN4U_RAM(dev);
@@ -548,7 +548,7 @@ static void ram_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo ram_info = {
-.name  = TYPE_SUN4U_MEMORY,
+.name  = TYPE_SUN4U_RAM,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(RamDevice),
 .class_init= ram_class_init,
-- 
2.26.2




[PATCH 30/63] versatile: Rename TYPE_VERSATILE_PCI to TYPE_PCI_VPB

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Peter Maydell 
Cc: qemu-...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/pci-host/versatile.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
index 7b6a754b8b..9da352c070 100644
--- a/hw/pci-host/versatile.c
+++ b/hw/pci-host/versatile.c
@@ -157,9 +157,9 @@ static const VMStateDescription pci_vpb_vmstate = {
 }
 };
 
-#define TYPE_VERSATILE_PCI "versatile_pci"
+#define TYPE_PCI_VPB "versatile_pci"
 DECLARE_INSTANCE_CHECKER(PCIVPBState, PCI_VPB,
- TYPE_VERSATILE_PCI)
+ TYPE_PCI_VPB)
 
 #define TYPE_PCI_VPB_HOST "versatile_pci_host"
 DECLARE_INSTANCE_CHECKER(PCIDevice, PCI_VPB_HOST,
@@ -514,7 +514,7 @@ static void pci_vpb_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo pci_vpb_info = {
-.name  = TYPE_VERSATILE_PCI,
+.name  = TYPE_PCI_VPB,
 .parent= TYPE_PCI_HOST_BRIDGE,
 .instance_size = sizeof(PCIVPBState),
 .instance_init = pci_vpb_init,
@@ -534,7 +534,7 @@ static void pci_realview_init(Object *obj)
 
 static const TypeInfo pci_realview_info = {
 .name  = "realview_pci",
-.parent= TYPE_VERSATILE_PCI,
+.parent= TYPE_PCI_VPB,
 .instance_init = pci_realview_init,
 };
 
-- 
2.26.2




[PATCH 28/63] tusb6010: Rename TYPE_TUSB6010 to TYPE_TUSB

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/usb/tusb6010.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
index 2bee3ae59f..9b35c1d4b8 100644
--- a/hw/usb/tusb6010.c
+++ b/hw/usb/tusb6010.c
@@ -30,10 +30,10 @@
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
-#define TYPE_TUSB6010 "tusb6010"
+#define TYPE_TUSB "tusb6010"
 typedef struct TUSBState TUSBState;
 DECLARE_INSTANCE_CHECKER(TUSBState, TUSB,
- TYPE_TUSB6010)
+ TYPE_TUSB)
 
 struct TUSBState {
 SysBusDevice parent_obj;
@@ -838,7 +838,7 @@ static void tusb6010_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo tusb6010_info = {
-.name  = TYPE_TUSB6010,
+.name  = TYPE_TUSB,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(TUSBState),
 .class_init= tusb6010_class_init,
-- 
2.26.2




[PATCH 25/63] scsi: Rename TYPE_DC390_DEVICE to TYPE_DC390

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: qemu-devel@nongnu.org
---
 hw/scsi/esp-pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 2b1198380b..58398609be 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -416,9 +416,9 @@ struct DC390State {
 };
 typedef struct DC390State DC390State;
 
-#define TYPE_DC390_DEVICE "dc390"
+#define TYPE_DC390 "dc390"
 DECLARE_INSTANCE_CHECKER(DC390State, DC390,
- TYPE_DC390_DEVICE)
+ TYPE_DC390)
 
 #define EE_ADAPT_SCSI_ID 64
 #define EE_MODE2 65
@@ -524,7 +524,7 @@ static void dc390_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo dc390_info = {
-.name = TYPE_DC390_DEVICE,
+.name = TYPE_DC390,
 .parent = TYPE_PCI_ESP,
 .instance_size = sizeof(DC390State),
 .class_init = dc390_class_init,
-- 
2.26.2




[PATCH 23/63] ramfb: Rename TYPE_RAMFB_DEVICE to TYPE_RAMFB

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Peter Maydell 
Cc: Gerd Hoffmann 
Cc: Paolo Bonzini 
Cc: Richard Henderson 
Cc: Eduardo Habkost 
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 
Cc: qemu-...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/hw/display/ramfb.h| 2 +-
 hw/arm/sysbus-fdt.c   | 2 +-
 hw/arm/virt.c | 2 +-
 hw/display/ramfb-standalone.c | 4 ++--
 hw/i386/pc_piix.c | 2 +-
 hw/i386/pc_q35.c  | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/hw/display/ramfb.h b/include/hw/display/ramfb.h
index b33a2c467b..c4b0150c88 100644
--- a/include/hw/display/ramfb.h
+++ b/include/hw/display/ramfb.h
@@ -7,6 +7,6 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s);
 RAMFBState *ramfb_setup(Error **errp);
 
 /* ramfb-standalone.c */
-#define TYPE_RAMFB_DEVICE "ramfb"
+#define TYPE_RAMFB "ramfb"
 
 #endif /* RAMFB_H */
diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c
index 6b6906f4cf..e8baa118a6 100644
--- a/hw/arm/sysbus-fdt.c
+++ b/hw/arm/sysbus-fdt.c
@@ -489,7 +489,7 @@ static const BindingEntry bindings[] = {
 VFIO_PLATFORM_BINDING("amd,xgbe-seattle-v1a", add_amd_xgbe_fdt_node),
 #endif
 TYPE_BINDING(TYPE_TPM_TIS_SYSBUS, add_tpm_tis_fdt_node),
-TYPE_BINDING(TYPE_RAMFB_DEVICE, no_fdt_node),
+TYPE_BINDING(TYPE_RAMFB, no_fdt_node),
 TYPE_BINDING("", NULL), /* last element */
 };
 
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index acf9bfbece..bf81b5a373 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2414,7 +2414,7 @@ static void virt_machine_class_init(ObjectClass *oc, void 
*data)
 mc->max_cpus = 512;
 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC);
 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE);
-machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
+machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB);
 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_PLATFORM);
 machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
 mc->block_default_type = IF_VIRTIO;
diff --git a/hw/display/ramfb-standalone.c b/hw/display/ramfb-standalone.c
index 8c0094397f..a86730393b 100644
--- a/hw/display/ramfb-standalone.c
+++ b/hw/display/ramfb-standalone.c
@@ -9,7 +9,7 @@
 
 typedef struct RAMFBStandaloneState RAMFBStandaloneState;
 DECLARE_INSTANCE_CHECKER(RAMFBStandaloneState, RAMFB,
- TYPE_RAMFB_DEVICE)
+ TYPE_RAMFB)
 
 struct RAMFBStandaloneState {
 SysBusDevice parent_obj;
@@ -51,7 +51,7 @@ static void ramfb_class_initfn(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo ramfb_info = {
-.name  = TYPE_RAMFB_DEVICE,
+.name  = TYPE_RAMFB,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(RAMFBStandaloneState),
 .class_init= ramfb_class_initfn,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 32b1453e6a..7ac4e65820 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -422,7 +422,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
 m->desc = "Standard PC (i440FX + PIIX, 1996)";
 m->default_machine_opts = "firmware=bios-256k.bin";
 m->default_display = "std";
-machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
+machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB);
 machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
 }
 
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 0cb9c18cd4..dd2223b659 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -348,7 +348,7 @@ static void pc_q35_machine_options(MachineClass *m)
 m->no_floppy = 1;
 machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
 machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
-machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
+machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB);
 machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
 m->max_cpus = 288;
 }
-- 
2.26.2




[PATCH 24/63] scsi: Rename TYPE_AM53C974_DEVICE to TYPE_PCI_ESP

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: qemu-devel@nongnu.org
---
 hw/scsi/esp-pci.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 2ce96dc56e..2b1198380b 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -35,11 +35,11 @@
 #include "qemu/module.h"
 #include "qom/object.h"
 
-#define TYPE_AM53C974_DEVICE "am53c974"
+#define TYPE_PCI_ESP "am53c974"
 
 typedef struct PCIESPState PCIESPState;
 DECLARE_INSTANCE_CHECKER(PCIESPState, PCI_ESP,
- TYPE_AM53C974_DEVICE)
+ TYPE_PCI_ESP)
 
 #define DMA_CMD   0x0
 #define DMA_STC   0x1
@@ -400,7 +400,7 @@ static void esp_pci_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo esp_pci_info = {
-.name = TYPE_AM53C974_DEVICE,
+.name = TYPE_PCI_ESP,
 .parent = TYPE_PCI_DEVICE,
 .instance_size = sizeof(PCIESPState),
 .class_init = esp_pci_class_init,
@@ -525,7 +525,7 @@ static void dc390_class_init(ObjectClass *klass, void *data)
 
 static const TypeInfo dc390_info = {
 .name = TYPE_DC390_DEVICE,
-.parent = TYPE_AM53C974_DEVICE,
+.parent = TYPE_PCI_ESP,
 .instance_size = sizeof(DC390State),
 .class_init = dc390_class_init,
 };
-- 
2.26.2




[PATCH 18/63] mips: Rename TYPE_MIPS_BOSTON to TYPE_BOSTON

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Paul Burton 
Cc: Aleksandar Rikalo 
Cc: Aleksandar Markovic 
Cc: Aurelien Jarno 
Cc: Jiaxun Yang 
Cc: qemu-devel@nongnu.org
---
 hw/mips/boston.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 1b3f69e949..17720a08c2 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -43,10 +43,10 @@
 #include 
 #include "qom/object.h"
 
-#define TYPE_MIPS_BOSTON "mips-boston"
+#define TYPE_BOSTON "mips-boston"
 typedef struct BostonState BostonState;
 DECLARE_INSTANCE_CHECKER(BostonState, BOSTON,
- TYPE_MIPS_BOSTON)
+ TYPE_BOSTON)
 
 struct BostonState {
 SysBusDevice parent_obj;
@@ -252,7 +252,7 @@ static const MemoryRegionOps boston_platreg_ops = {
 };
 
 static const TypeInfo boston_device = {
-.name  = TYPE_MIPS_BOSTON,
+.name  = TYPE_BOSTON,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(BostonState),
 };
@@ -444,7 +444,7 @@ static void boston_mach_init(MachineState *machine)
 exit(1);
 }
 
-dev = qdev_new(TYPE_MIPS_BOSTON);
+dev = qdev_new(TYPE_BOSTON);
 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), _fatal);
 
 s = BOSTON(dev);
-- 
2.26.2




[PATCH 22/63] pxb: Rename TYPE_PXB_PCIE_DEVICE to TYPE_PXB_PCIE_DEV

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 
Cc: qemu-devel@nongnu.org
---
 hw/pci-bridge/pci_expander_bridge.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/pci-bridge/pci_expander_bridge.c 
b/hw/pci-bridge/pci_expander_bridge.c
index 42e58d5850..1517ae5fa2 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -46,9 +46,9 @@ typedef struct PXBDev PXBDev;
 DECLARE_INSTANCE_CHECKER(PXBDev, PXB_DEV,
  TYPE_PXB_DEV)
 
-#define TYPE_PXB_PCIE_DEVICE "pxb-pcie"
+#define TYPE_PXB_PCIE_DEV "pxb-pcie"
 DECLARE_INSTANCE_CHECKER(PXBDev, PXB_PCIE_DEV,
- TYPE_PXB_PCIE_DEVICE)
+ TYPE_PXB_PCIE_DEV)
 
 struct PXBDev {
 /*< private >*/
@@ -360,7 +360,7 @@ static void pxb_pcie_dev_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo pxb_pcie_dev_info = {
-.name  = TYPE_PXB_PCIE_DEVICE,
+.name  = TYPE_PXB_PCIE_DEV,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PXBDev),
 .class_init= pxb_pcie_dev_class_init,
-- 
2.26.2




[PATCH 19/63] mptsas: Rename TYPE_MPTSAS1068 to TYPE_MPT_SAS

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Paolo Bonzini 
Cc: Fam Zheng 
Cc: qemu-devel@nongnu.org
---
 hw/scsi/mptsas.h | 4 ++--
 hw/scsi/mptsas.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/mptsas.h b/hw/scsi/mptsas.h
index b85ac1a5fc..c618f686a3 100644
--- a/hw/scsi/mptsas.h
+++ b/hw/scsi/mptsas.h
@@ -14,10 +14,10 @@
 
 typedef struct MPTSASRequest MPTSASRequest;
 
-#define TYPE_MPTSAS1068 "mptsas1068"
+#define TYPE_MPT_SAS "mptsas1068"
 typedef struct MPTSASState MPTSASState;
 DECLARE_INSTANCE_CHECKER(MPTSASState, MPT_SAS,
- TYPE_MPTSAS1068)
+ TYPE_MPT_SAS)
 
 enum {
 DOORBELL_NONE,
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index 135e7d96e4..0dbb70c17b 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -1434,7 +1434,7 @@ static void mptsas1068_class_init(ObjectClass *oc, void 
*data)
 }
 
 static const TypeInfo mptsas_info = {
-.name = TYPE_MPTSAS1068,
+.name = TYPE_MPT_SAS,
 .parent = TYPE_PCI_DEVICE,
 .instance_size = sizeof(MPTSASState),
 .class_init = mptsas1068_class_init,
-- 
2.26.2




[PATCH 16/63] i8259: Rename TYPE_KVM_I8259 to TYPE_KVM_PIC

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 
Cc: Paolo Bonzini 
Cc: Richard Henderson 
Cc: Eduardo Habkost 
Cc: qemu-devel@nongnu.org
---
 hw/i386/kvm/i8259.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c
index 3f8bf69e9c..687c0cd536 100644
--- a/hw/i386/kvm/i8259.c
+++ b/hw/i386/kvm/i8259.c
@@ -19,10 +19,10 @@
 #include "sysemu/kvm.h"
 #include "qom/object.h"
 
-#define TYPE_KVM_I8259 "kvm-i8259"
+#define TYPE_KVM_PIC "kvm-i8259"
 typedef struct KVMPICClass KVMPICClass;
 DECLARE_CLASS_CHECKERS(KVMPICClass, KVM_PIC,
-   TYPE_KVM_I8259)
+   TYPE_KVM_PIC)
 
 /**
  * KVMPICClass:
@@ -133,8 +133,8 @@ static void kvm_pic_realize(DeviceState *dev, Error **errp)
 
 qemu_irq *kvm_i8259_init(ISABus *bus)
 {
-i8259_init_chip(TYPE_KVM_I8259, bus, true);
-i8259_init_chip(TYPE_KVM_I8259, bus, false);
+i8259_init_chip(TYPE_KVM_PIC, bus, true);
+i8259_init_chip(TYPE_KVM_PIC, bus, false);
 
 return qemu_allocate_irqs(kvm_pic_set_irq, NULL, ISA_NUM_IRQS);
 }
@@ -152,7 +152,7 @@ static void kvm_i8259_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo kvm_i8259_info = {
-.name = TYPE_KVM_I8259,
+.name = TYPE_KVM_PIC,
 .parent = TYPE_PIC_COMMON,
 .instance_size = sizeof(PICCommonState),
 .class_init = kvm_i8259_class_init,
-- 
2.26.2




[PATCH 21/63] pxb: Rename TYPE_PXB_DEVICE to TYPE_PXB_DEV

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Michael S. Tsirkin" 
Cc: Marcel Apfelbaum 
Cc: qemu-devel@nongnu.org
---
 hw/pci-bridge/pci_expander_bridge.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/pci-bridge/pci_expander_bridge.c 
b/hw/pci-bridge/pci_expander_bridge.c
index aedded1064..42e58d5850 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -41,10 +41,10 @@ struct PXBBus {
 char bus_path[8];
 };
 
-#define TYPE_PXB_DEVICE "pxb"
+#define TYPE_PXB_DEV "pxb"
 typedef struct PXBDev PXBDev;
 DECLARE_INSTANCE_CHECKER(PXBDev, PXB_DEV,
- TYPE_PXB_DEVICE)
+ TYPE_PXB_DEV)
 
 #define TYPE_PXB_PCIE_DEVICE "pxb-pcie"
 DECLARE_INSTANCE_CHECKER(PXBDev, PXB_PCIE_DEV,
@@ -322,7 +322,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo pxb_dev_info = {
-.name  = TYPE_PXB_DEVICE,
+.name  = TYPE_PXB_DEV,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(PXBDev),
 .class_init= pxb_dev_class_init,
-- 
2.26.2




[PATCH 12/63] etrax: Rename TYPE_ETRAX_FS_SERIAL to TYPE_ETRAX_SERIAL

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Edgar E. Iglesias" 
Cc: "Marc-André Lureau" 
Cc: Paolo Bonzini 
Cc: qemu-devel@nongnu.org
---
 hw/char/etraxfs_ser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c
index d9fba2ae6c..6bfc6d376d 100644
--- a/hw/char/etraxfs_ser.c
+++ b/hw/char/etraxfs_ser.c
@@ -49,10 +49,10 @@
 #define STAT_TR_IDLE 22
 #define STAT_TR_RDY  24
 
-#define TYPE_ETRAX_FS_SERIAL "etraxfs,serial"
+#define TYPE_ETRAX_SERIAL "etraxfs,serial"
 typedef struct ETRAXSerial ETRAXSerial;
 DECLARE_INSTANCE_CHECKER(ETRAXSerial, ETRAX_SERIAL,
- TYPE_ETRAX_FS_SERIAL)
+ TYPE_ETRAX_SERIAL)
 
 struct ETRAXSerial {
 SysBusDevice parent_obj;
@@ -251,7 +251,7 @@ static void etraxfs_ser_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo etraxfs_ser_info = {
-.name  = TYPE_ETRAX_FS_SERIAL,
+.name  = TYPE_ETRAX_SERIAL,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(ETRAXSerial),
 .instance_init = etraxfs_ser_init,
-- 
2.26.2




[PATCH 17/63] intel-hda: Rename TYPE_INTEL_HDA_GENERIC to TYPE_INTEL_HDA

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/audio/intel-hda.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 4330213fff..28c4edeece 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -202,10 +202,10 @@ struct IntelHDAState {
 bool old_msi_addr;
 };
 
-#define TYPE_INTEL_HDA_GENERIC "intel-hda-generic"
+#define TYPE_INTEL_HDA "intel-hda-generic"
 
 DECLARE_INSTANCE_CHECKER(IntelHDAState, INTEL_HDA,
- TYPE_INTEL_HDA_GENERIC)
+ TYPE_INTEL_HDA)
 
 struct IntelHDAReg {
 const char *name;  /* register name */
@@ -1257,7 +1257,7 @@ static void intel_hda_class_init_ich9(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo intel_hda_info = {
-.name  = TYPE_INTEL_HDA_GENERIC,
+.name  = TYPE_INTEL_HDA,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(IntelHDAState),
 .class_init= intel_hda_class_init,
@@ -1270,13 +1270,13 @@ static const TypeInfo intel_hda_info = {
 
 static const TypeInfo intel_hda_info_ich6 = {
 .name  = "intel-hda",
-.parent= TYPE_INTEL_HDA_GENERIC,
+.parent= TYPE_INTEL_HDA,
 .class_init= intel_hda_class_init_ich6,
 };
 
 static const TypeInfo intel_hda_info_ich9 = {
 .name  = "ich9-intel-hda",
-.parent= TYPE_INTEL_HDA_GENERIC,
+.parent= TYPE_INTEL_HDA,
 .class_init= intel_hda_class_init_ich9,
 };
 
-- 
2.26.2




[PATCH 13/63] etrax: Rename TYPE_ETRAX_FS_TIMER to TYPE_ETRAX_TIMER

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Edgar E. Iglesias" 
Cc: qemu-devel@nongnu.org
---
 hw/timer/etraxfs_timer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index 48f2e3ade2..585e934ed5 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -48,10 +48,10 @@
 #define R_INTR0x50
 #define R_MASKED_INTR 0x54
 
-#define TYPE_ETRAX_FS_TIMER "etraxfs,timer"
+#define TYPE_ETRAX_TIMER "etraxfs,timer"
 typedef struct ETRAXTimerState ETRAXTimerState;
 DECLARE_INSTANCE_CHECKER(ETRAXTimerState, ETRAX_TIMER,
- TYPE_ETRAX_FS_TIMER)
+ TYPE_ETRAX_TIMER)
 
 struct ETRAXTimerState {
 SysBusDevice parent_obj;
@@ -354,7 +354,7 @@ static void etraxfs_timer_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo etraxfs_timer_info = {
-.name  = TYPE_ETRAX_FS_TIMER,
+.name  = TYPE_ETRAX_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(ETRAXTimerState),
 .class_init= etraxfs_timer_class_init,
-- 
2.26.2




[PATCH 06/63] dev-smartcard-reader: Rename CCID_DEV_NAME to TYPE_USB_CCID_DEV

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Gerd Hoffmann 
Cc: qemu-devel@nongnu.org
---
 hw/usb/dev-smartcard-reader.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 432508c478..59b2248f34 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -60,10 +60,10 @@ do { \
 #define D_MORE_INFO 3
 #define D_VERBOSE 4
 
-#define CCID_DEV_NAME "usb-ccid"
+#define TYPE_USB_CCID_DEV "usb-ccid"
 typedef struct USBCCIDState USBCCIDState;
 DECLARE_INSTANCE_CHECKER(USBCCIDState, USB_CCID_DEV,
- CCID_DEV_NAME)
+ TYPE_USB_CCID_DEV)
 /*
  * The two options for variable sized buffers:
  * make them constant size, for large enough constant,
@@ -1462,7 +1462,7 @@ static void ccid_class_initfn(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo ccid_info = {
-.name  = CCID_DEV_NAME,
+.name  = TYPE_USB_CCID_DEV,
 .parent= TYPE_USB_DEVICE,
 .instance_size = sizeof(USBCCIDState),
 .class_init= ccid_class_initfn,
@@ -1495,7 +1495,7 @@ static void ccid_register_types(void)
 type_register_static(_bus_info);
 type_register_static(_card_type_info);
 type_register_static(_info);
-usb_legacy_register(CCID_DEV_NAME, "ccid", NULL);
+usb_legacy_register(TYPE_USB_CCID_DEV, "ccid", NULL);
 }
 
 type_init(ccid_register_types)
-- 
2.26.2




[PATCH 20/63] pc87312: Rename TYPE_PC87312_SUPERIO to TYPE_PC87312

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Hervé Poussineau" 
Cc: qemu-...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/hw/isa/pc87312.h | 4 ++--
 hw/isa/pc87312.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/hw/isa/pc87312.h b/include/hw/isa/pc87312.h
index a65168a157..da8dc5ddf5 100644
--- a/include/hw/isa/pc87312.h
+++ b/include/hw/isa/pc87312.h
@@ -29,10 +29,10 @@
 #include "qom/object.h"
 
 
-#define TYPE_PC87312_SUPERIO "pc87312"
+#define TYPE_PC87312 "pc87312"
 typedef struct PC87312State PC87312State;
 DECLARE_INSTANCE_CHECKER(PC87312State, PC87312,
- TYPE_PC87312_SUPERIO)
+ TYPE_PC87312)
 
 struct PC87312State {
 /*< private >*/
diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c
index 0cacbbc91b..8d7b8d3db2 100644
--- a/hw/isa/pc87312.c
+++ b/hw/isa/pc87312.c
@@ -371,7 +371,7 @@ static void pc87312_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo pc87312_type_info = {
-.name  = TYPE_PC87312_SUPERIO,
+.name  = TYPE_PC87312,
 .parent= TYPE_ISA_SUPERIO,
 .instance_size = sizeof(PC87312State),
 .instance_init = pc87312_initfn,
-- 
2.26.2




[PATCH 11/63] edu: Rename TYPE_PCI_EDU_DEVICE to TYPE_EDU

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Jiri Slaby 
Cc: qemu-devel@nongnu.org
---
 hw/misc/edu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 0ff9d1ac78..b69728838d 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -33,10 +33,10 @@
 #include "qemu/module.h"
 #include "qapi/visitor.h"
 
-#define TYPE_PCI_EDU_DEVICE "edu"
+#define TYPE_EDU "edu"
 typedef struct EduState EduState;
 DECLARE_INSTANCE_CHECKER(EduState, EDU,
- TYPE_PCI_EDU_DEVICE)
+ TYPE_EDU)
 
 #define FACT_IRQ0x0001
 #define DMA_IRQ 0x0100
@@ -429,7 +429,7 @@ static void pci_edu_register_types(void)
 { },
 };
 static const TypeInfo edu_info = {
-.name  = TYPE_PCI_EDU_DEVICE,
+.name  = TYPE_EDU,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(EduState),
 .instance_init = edu_instance_init,
-- 
2.26.2




[PATCH 15/63] i8259: Rename TYPE_I8259 to TYPE_PIC

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Michael S. Tsirkin" 
Cc: Paolo Bonzini 
Cc: qemu-devel@nongnu.org
---
 hw/intc/i8259.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c
index 344fd04db1..e536cc90be 100644
--- a/hw/intc/i8259.c
+++ b/hw/intc/i8259.c
@@ -37,10 +37,10 @@
 
 //#define DEBUG_IRQ_LATENCY
 
-#define TYPE_I8259 "isa-i8259"
+#define TYPE_PIC "isa-i8259"
 typedef struct PICClass PICClass;
 DECLARE_CLASS_CHECKERS(PICClass, PIC,
-   TYPE_I8259)
+   TYPE_PIC)
 
 /**
  * PICClass:
@@ -418,7 +418,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
 
 irq_set = g_new0(qemu_irq, ISA_NUM_IRQS);
 
-isadev = i8259_init_chip(TYPE_I8259, bus, true);
+isadev = i8259_init_chip(TYPE_PIC, bus, true);
 dev = DEVICE(isadev);
 
 qdev_connect_gpio_out(dev, 0, parent_irq);
@@ -428,7 +428,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
 
 isa_pic = dev;
 
-isadev = i8259_init_chip(TYPE_I8259, bus, false);
+isadev = i8259_init_chip(TYPE_PIC, bus, false);
 dev = DEVICE(isadev);
 
 qdev_connect_gpio_out(dev, 0, irq_set[2]);
@@ -451,7 +451,7 @@ static void i8259_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo i8259_info = {
-.name   = TYPE_I8259,
+.name   = TYPE_PIC,
 .instance_size = sizeof(PICCommonState),
 .parent = TYPE_PIC_COMMON,
 .class_init = i8259_class_init,
-- 
2.26.2




[PATCH 08/63] vfio: Rename VFIO_AP_DEVICE_TYPE to TYPE_VFIO_AP_DEVICE

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Cornelia Huck 
Cc: Thomas Huth 
Cc: Christian Borntraeger 
Cc: Tony Krowiak 
Cc: Halil Pasic 
Cc: Pierre Morel 
Cc: Alex Williamson 
Cc: qemu-s3...@nongnu.org
Cc: qemu-devel@nongnu.org
---
 hw/vfio/ap.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index 68ed059b39..582c091a24 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -30,7 +30,7 @@
 #include "exec/address-spaces.h"
 #include "qom/object.h"
 
-#define VFIO_AP_DEVICE_TYPE  "vfio-ap"
+#define TYPE_VFIO_AP_DEVICE  "vfio-ap"
 
 struct VFIOAPDevice {
 APDevice apdev;
@@ -39,7 +39,7 @@ struct VFIOAPDevice {
 typedef struct VFIOAPDevice VFIOAPDevice;
 
 DECLARE_INSTANCE_CHECKER(VFIOAPDevice, VFIO_AP_DEVICE,
- VFIO_AP_DEVICE_TYPE)
+ TYPE_VFIO_AP_DEVICE)
 
 static void vfio_ap_compute_needs_reset(VFIODevice *vdev)
 {
@@ -72,7 +72,7 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, 
Error **errp)
 
 if (!group_path) {
 error_setg(errp, "%s: no iommu_group found for %s: %s",
-   VFIO_AP_DEVICE_TYPE, vapdev->vdev.sysfsdev, 
gerror->message);
+   TYPE_VFIO_AP_DEVICE, vapdev->vdev.sysfsdev, 
gerror->message);
 g_error_free(gerror);
 return NULL;
 }
@@ -176,7 +176,7 @@ static void vfio_ap_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo vfio_ap_info = {
-.name = VFIO_AP_DEVICE_TYPE,
+.name = TYPE_VFIO_AP_DEVICE,
 .parent = TYPE_AP_DEVICE,
 .instance_size = sizeof(VFIOAPDevice),
 .class_init = vfio_ap_class_init,
-- 
2.26.2




[PATCH 09/63] vmcoreinfo: Rename VMCOREINFO_DEVICE to TYPE_VMCOREINFO

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Marc-André Lureau" 
Cc: qemu-devel@nongnu.org
---
 include/hw/misc/vmcoreinfo.h | 6 +++---
 hw/misc/vmcoreinfo.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/hw/misc/vmcoreinfo.h b/include/hw/misc/vmcoreinfo.h
index ebada6617a..6e523c3892 100644
--- a/include/hw/misc/vmcoreinfo.h
+++ b/include/hw/misc/vmcoreinfo.h
@@ -16,10 +16,10 @@
 #include "standard-headers/linux/qemu_fw_cfg.h"
 #include "qom/object.h"
 
-#define VMCOREINFO_DEVICE "vmcoreinfo"
+#define TYPE_VMCOREINFO "vmcoreinfo"
 typedef struct VMCoreInfoState VMCoreInfoState;
 DECLARE_INSTANCE_CHECKER(VMCoreInfoState, VMCOREINFO,
- VMCOREINFO_DEVICE)
+ TYPE_VMCOREINFO)
 
 typedef struct fw_cfg_vmcoreinfo FWCfgVMCoreInfo;
 
@@ -33,7 +33,7 @@ struct VMCoreInfoState {
 /* returns NULL unless there is exactly one device */
 static inline VMCoreInfoState *vmcoreinfo_find(void)
 {
-Object *o = object_resolve_path_type("", VMCOREINFO_DEVICE, NULL);
+Object *o = object_resolve_path_type("", TYPE_VMCOREINFO, NULL);
 
 return o ? VMCOREINFO(o) : NULL;
 }
diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
index a9d718fc23..a68e3ad68c 100644
--- a/hw/misc/vmcoreinfo.c
+++ b/hw/misc/vmcoreinfo.c
@@ -47,13 +47,13 @@ static void vmcoreinfo_realize(DeviceState *dev, Error 
**errp)
  */
 if (!vmcoreinfo_find()) {
 error_setg(errp, "at most one %s device is permitted",
-   VMCOREINFO_DEVICE);
+   TYPE_VMCOREINFO);
 return;
 }
 
 if (!fw_cfg || !fw_cfg->dma_enabled) {
 error_setg(errp, "%s device requires fw_cfg with DMA",
-   VMCOREINFO_DEVICE);
+   TYPE_VMCOREINFO);
 return;
 }
 
@@ -94,7 +94,7 @@ static void vmcoreinfo_device_class_init(ObjectClass *klass, 
void *data)
 }
 
 static const TypeInfo vmcoreinfo_device_info = {
-.name  = VMCOREINFO_DEVICE,
+.name  = TYPE_VMCOREINFO,
 .parent= TYPE_DEVICE,
 .instance_size = sizeof(VMCoreInfoState),
 .class_init= vmcoreinfo_device_class_init,
-- 
2.26.2




[PATCH 07/63] rdma: Rename PVRDMA_HW_NAME to TYPE_PVRDMA_DEV

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: Yuval Shaia 
Cc: Marcel Apfelbaum 
Cc: qemu-devel@nongnu.org
---
 hw/rdma/vmw/pvrdma.h  | 4 ++--
 hw/rdma/vmw/pvrdma_main.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h
index 1d36a76f1e..e7e610b223 100644
--- a/hw/rdma/vmw/pvrdma.h
+++ b/hw/rdma/vmw/pvrdma.h
@@ -50,7 +50,7 @@
 #define INTR_VEC_CMD_COMPLETION_Q2
 
 /* HW attributes */
-#define PVRDMA_HW_NAME   "pvrdma"
+#define TYPE_PVRDMA_DEV   "pvrdma"
 #define PVRDMA_HW_VERSION17
 #define PVRDMA_FW_VERSION14
 
@@ -102,7 +102,7 @@ struct PVRDMADev {
 };
 typedef struct PVRDMADev PVRDMADev;
 DECLARE_INSTANCE_CHECKER(PVRDMADev, PVRDMA_DEV,
- PVRDMA_HW_NAME)
+ TYPE_PVRDMA_DEV)
 
 static inline int get_reg_val(PVRDMADev *dev, hwaddr addr, uint32_t *val)
 {
diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 77b1235a3f..a08f720bfd 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -697,7 +697,7 @@ static void pvrdma_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo pvrdma_info = {
-.name = PVRDMA_HW_NAME,
+.name = TYPE_PVRDMA_DEV,
 .parent = TYPE_PCI_DEVICE,
 .instance_size = sizeof(PVRDMADev),
 .class_init = pvrdma_class_init,
-- 
2.26.2




[PATCH 14/63] i8254: Rename TYPE_I8254 to TYPE_PIT

2020-09-02 Thread Eduardo Habkost
This will make the type name constant consistent with the name of
the type checking macro.

Signed-off-by: Eduardo Habkost 
---
Cc: "Michael S. Tsirkin" 
Cc: Paolo Bonzini 
Cc: qemu-devel@nongnu.org
---
 include/hw/timer/i8254.h | 4 ++--
 hw/timer/i8254.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h
index 1a522a2457..ddd925074f 100644
--- a/include/hw/timer/i8254.h
+++ b/include/hw/timer/i8254.h
@@ -45,7 +45,7 @@ typedef struct PITCommonClass PITCommonClass;
 DECLARE_OBJ_CHECKERS(PITCommonState, PITCommonClass,
  PIT_COMMON, TYPE_PIT_COMMON)
 
-#define TYPE_I8254 "isa-pit"
+#define TYPE_PIT "isa-pit"
 #define TYPE_KVM_I8254 "kvm-pit"
 
 static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq,
@@ -54,7 +54,7 @@ static inline ISADevice *i8254_pit_init(ISABus *bus, int 
base, int isa_irq,
 DeviceState *dev;
 ISADevice *d;
 
-d = isa_new(TYPE_I8254);
+d = isa_new(TYPE_PIT);
 dev = DEVICE(d);
 qdev_prop_set_uint32(dev, "iobase", base);
 isa_realize_and_unref(d, bus, _fatal);
diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c
index c01ee2c72a..86f455f67e 100644
--- a/hw/timer/i8254.c
+++ b/hw/timer/i8254.c
@@ -39,7 +39,7 @@
 
 typedef struct PITClass PITClass;
 DECLARE_CLASS_CHECKERS(PITClass, PIT,
-   TYPE_I8254)
+   TYPE_PIT)
 
 struct PITClass {
 PITCommonClass parent_class;
@@ -370,7 +370,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo pit_info = {
-.name  = TYPE_I8254,
+.name  = TYPE_PIT,
 .parent= TYPE_PIT_COMMON,
 .instance_size = sizeof(PITCommonState),
 .class_init= pit_class_initfn,
-- 
2.26.2




  1   2   3   4   5   6   >