qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i386/kvm: The value passed to strerror should be positive
@ 2021-05-19 11:35 Dmitry Voronetskiy
  2021-05-19 13:43 ` Markus Armbruster
  2021-06-05 19:01 ` Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Voronetskiy @ 2021-05-19 11:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Dmitry Voronetskiy

From: Dmitry Voronetskiy <vda1999@yandex.ru>

Signed-off-by: Dmitry Voronetskiy <vda1999@yandex.ru>

---
 hw/i386/kvm/apic.c   |  2 +-
 hw/i386/kvm/clock.c  |  4 ++--
 hw/i386/kvm/i8254.c  | 10 +++++-----
 hw/i386/kvm/i8259.c  |  4 ++--
 hw/i386/kvm/ioapic.c |  4 ++--
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
index 52ff490910..1e89ca0899 100644
--- a/hw/i386/kvm/apic.c
+++ b/hw/i386/kvm/apic.c
@@ -145,7 +145,7 @@ static void kvm_apic_put(CPUState *cs, run_on_cpu_data data)
 
     ret = kvm_vcpu_ioctl(CPU(s->cpu), KVM_SET_LAPIC, &kapic);
     if (ret < 0) {
-        fprintf(stderr, "KVM_SET_LAPIC failed: %s\n", strerror(ret));
+        fprintf(stderr, "KVM_SET_LAPIC failed: %s\n", strerror(-ret));
         abort();
     }
 }
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index efbc1e0d12..df70b4a033 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -105,7 +105,7 @@ static void kvm_update_clock(KVMClockState *s)
 
     ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);
     if (ret < 0) {
-        fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret));
+        fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(-ret));
                 abort();
     }
     s->clock = data.clock;
@@ -189,7 +189,7 @@ static void kvmclock_vm_state_change(void *opaque, bool running,
         data.clock = s->clock;
         ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
         if (ret < 0) {
-            fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(ret));
+            fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(-ret));
             abort();
         }
 
diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index c558893961..fa68669e8a 100644
--- a/hw/i386/kvm/i8254.c
+++ b/hw/i386/kvm/i8254.c
@@ -104,7 +104,7 @@ static void kvm_pit_get(PITCommonState *pit)
     if (kvm_has_pit_state2()) {
         ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT2, &kpit);
         if (ret < 0) {
-            fprintf(stderr, "KVM_GET_PIT2 failed: %s\n", strerror(ret));
+            fprintf(stderr, "KVM_GET_PIT2 failed: %s\n", strerror(-ret));
             abort();
         }
         pit->channels[0].irq_disabled = kpit.flags & KVM_PIT_FLAGS_HPET_LEGACY;
@@ -115,7 +115,7 @@ static void kvm_pit_get(PITCommonState *pit)
          */
         ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT, &kpit);
         if (ret < 0) {
-            fprintf(stderr, "KVM_GET_PIT failed: %s\n", strerror(ret));
+            fprintf(stderr, "KVM_GET_PIT failed: %s\n", strerror(-ret));
             abort();
         }
     }
@@ -180,7 +180,7 @@ static void kvm_pit_put(PITCommonState *pit)
     if (ret < 0) {
         fprintf(stderr, "%s failed: %s\n",
                 kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",
-                strerror(ret));
+                strerror(-ret));
         abort();
     }
 }
@@ -272,7 +272,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
     }
     if (ret < 0) {
         error_setg(errp, "Create kernel PIC irqchip failed: %s",
-                   strerror(ret));
+                   strerror(-ret));
         return;
     }
     switch (s->lost_tick_policy) {
@@ -286,7 +286,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
             if (ret < 0) {
                 error_setg(errp,
                            "Can't disable in-kernel PIT reinjection: %s",
-                           strerror(ret));
+                           strerror(-ret));
                 return;
             }
         }
diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c
index 3f8bf69e9c..d61bae4dc3 100644
--- a/hw/i386/kvm/i8259.c
+++ b/hw/i386/kvm/i8259.c
@@ -43,7 +43,7 @@ static void kvm_pic_get(PICCommonState *s)
     chip.chip_id = s->master ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE;
     ret = kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, &chip);
     if (ret < 0) {
-        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(ret));
+        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(-ret));
         abort();
     }
 
@@ -96,7 +96,7 @@ static void kvm_pic_put(PICCommonState *s)
 
     ret = kvm_vm_ioctl(kvm_state, KVM_SET_IRQCHIP, &chip);
     if (ret < 0) {
-        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(ret));
+        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(-ret));
         abort();
     }
 }
diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c
index 71a563181e..ee7c8ef68b 100644
--- a/hw/i386/kvm/ioapic.c
+++ b/hw/i386/kvm/ioapic.c
@@ -62,7 +62,7 @@ static void kvm_ioapic_get(IOAPICCommonState *s)
     chip.chip_id = KVM_IRQCHIP_IOAPIC;
     ret = kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, &chip);
     if (ret < 0) {
-        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(ret));
+        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(-ret));
         abort();
     }
 
@@ -95,7 +95,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s)
 
     ret = kvm_vm_ioctl(kvm_state, KVM_SET_IRQCHIP, &chip);
     if (ret < 0) {
-        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(ret));
+        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(-ret));
         abort();
     }
 }
-- 
2.25.1



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

* Re: [PATCH] i386/kvm: The value passed to strerror should be positive
  2021-05-19 11:35 [PATCH] i386/kvm: The value passed to strerror should be positive Dmitry Voronetskiy
@ 2021-05-19 13:43 ` Markus Armbruster
  2021-06-05 19:01 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2021-05-19 13:43 UTC (permalink / raw)
  To: Dmitry Voronetskiy; +Cc: qemu-trivial, Dmitry Voronetskiy, qemu-devel

Dmitry Voronetskiy <davoronetskiy@gmail.com> writes:

> From: Dmitry Voronetskiy <vda1999@yandex.ru>
>
> Signed-off-by: Dmitry Voronetskiy <vda1999@yandex.ru>

Reviewed-by: Markus Armbruster <armbru@redhat.com>



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

* Re: [PATCH] i386/kvm: The value passed to strerror should be positive
  2021-05-19 11:35 [PATCH] i386/kvm: The value passed to strerror should be positive Dmitry Voronetskiy
  2021-05-19 13:43 ` Markus Armbruster
@ 2021-06-05 19:01 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2021-06-05 19:01 UTC (permalink / raw)
  To: Dmitry Voronetskiy, qemu-devel; +Cc: qemu-trivial, Dmitry Voronetskiy

Le 19/05/2021 à 13:35, Dmitry Voronetskiy a écrit :
> From: Dmitry Voronetskiy <vda1999@yandex.ru>
> 
> Signed-off-by: Dmitry Voronetskiy <vda1999@yandex.ru>
> 
> ---
>  hw/i386/kvm/apic.c   |  2 +-
>  hw/i386/kvm/clock.c  |  4 ++--
>  hw/i386/kvm/i8254.c  | 10 +++++-----
>  hw/i386/kvm/i8259.c  |  4 ++--
>  hw/i386/kvm/ioapic.c |  4 ++--
>  5 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
> index 52ff490910..1e89ca0899 100644
> --- a/hw/i386/kvm/apic.c
> +++ b/hw/i386/kvm/apic.c
> @@ -145,7 +145,7 @@ static void kvm_apic_put(CPUState *cs, run_on_cpu_data data)
>  
>      ret = kvm_vcpu_ioctl(CPU(s->cpu), KVM_SET_LAPIC, &kapic);
>      if (ret < 0) {
> -        fprintf(stderr, "KVM_SET_LAPIC failed: %s\n", strerror(ret));
> +        fprintf(stderr, "KVM_SET_LAPIC failed: %s\n", strerror(-ret));
>          abort();
>      }
>  }
> diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
> index efbc1e0d12..df70b4a033 100644
> --- a/hw/i386/kvm/clock.c
> +++ b/hw/i386/kvm/clock.c
> @@ -105,7 +105,7 @@ static void kvm_update_clock(KVMClockState *s)
>  
>      ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);
>      if (ret < 0) {
> -        fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret));
> +        fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(-ret));
>                  abort();
>      }
>      s->clock = data.clock;
> @@ -189,7 +189,7 @@ static void kvmclock_vm_state_change(void *opaque, bool running,
>          data.clock = s->clock;
>          ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
>          if (ret < 0) {
> -            fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(ret));
> +            fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(-ret));
>              abort();
>          }
>  
> diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
> index c558893961..fa68669e8a 100644
> --- a/hw/i386/kvm/i8254.c
> +++ b/hw/i386/kvm/i8254.c
> @@ -104,7 +104,7 @@ static void kvm_pit_get(PITCommonState *pit)
>      if (kvm_has_pit_state2()) {
>          ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT2, &kpit);
>          if (ret < 0) {
> -            fprintf(stderr, "KVM_GET_PIT2 failed: %s\n", strerror(ret));
> +            fprintf(stderr, "KVM_GET_PIT2 failed: %s\n", strerror(-ret));
>              abort();
>          }
>          pit->channels[0].irq_disabled = kpit.flags & KVM_PIT_FLAGS_HPET_LEGACY;
> @@ -115,7 +115,7 @@ static void kvm_pit_get(PITCommonState *pit)
>           */
>          ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT, &kpit);
>          if (ret < 0) {
> -            fprintf(stderr, "KVM_GET_PIT failed: %s\n", strerror(ret));
> +            fprintf(stderr, "KVM_GET_PIT failed: %s\n", strerror(-ret));
>              abort();
>          }
>      }
> @@ -180,7 +180,7 @@ static void kvm_pit_put(PITCommonState *pit)
>      if (ret < 0) {
>          fprintf(stderr, "%s failed: %s\n",
>                  kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",
> -                strerror(ret));
> +                strerror(-ret));
>          abort();
>      }
>  }
> @@ -272,7 +272,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
>      }
>      if (ret < 0) {
>          error_setg(errp, "Create kernel PIC irqchip failed: %s",
> -                   strerror(ret));
> +                   strerror(-ret));
>          return;
>      }
>      switch (s->lost_tick_policy) {
> @@ -286,7 +286,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp)
>              if (ret < 0) {
>                  error_setg(errp,
>                             "Can't disable in-kernel PIT reinjection: %s",
> -                           strerror(ret));
> +                           strerror(-ret));
>                  return;
>              }
>          }
> diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c
> index 3f8bf69e9c..d61bae4dc3 100644
> --- a/hw/i386/kvm/i8259.c
> +++ b/hw/i386/kvm/i8259.c
> @@ -43,7 +43,7 @@ static void kvm_pic_get(PICCommonState *s)
>      chip.chip_id = s->master ? KVM_IRQCHIP_PIC_MASTER : KVM_IRQCHIP_PIC_SLAVE;
>      ret = kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, &chip);
>      if (ret < 0) {
> -        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(ret));
> +        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(-ret));
>          abort();
>      }
>  
> @@ -96,7 +96,7 @@ static void kvm_pic_put(PICCommonState *s)
>  
>      ret = kvm_vm_ioctl(kvm_state, KVM_SET_IRQCHIP, &chip);
>      if (ret < 0) {
> -        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(ret));
> +        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(-ret));
>          abort();
>      }
>  }
> diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c
> index 71a563181e..ee7c8ef68b 100644
> --- a/hw/i386/kvm/ioapic.c
> +++ b/hw/i386/kvm/ioapic.c
> @@ -62,7 +62,7 @@ static void kvm_ioapic_get(IOAPICCommonState *s)
>      chip.chip_id = KVM_IRQCHIP_IOAPIC;
>      ret = kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, &chip);
>      if (ret < 0) {
> -        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(ret));
> +        fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(-ret));
>          abort();
>      }
>  
> @@ -95,7 +95,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s)
>  
>      ret = kvm_vm_ioctl(kvm_state, KVM_SET_IRQCHIP, &chip);
>      if (ret < 0) {
> -        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(ret));
> +        fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(-ret));
>          abort();
>      }
>  }
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



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

end of thread, other threads:[~2021-06-05 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 11:35 [PATCH] i386/kvm: The value passed to strerror should be positive Dmitry Voronetskiy
2021-05-19 13:43 ` Markus Armbruster
2021-06-05 19:01 ` Laurent Vivier

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