All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] (no subject)
@ 2019-02-25 13:18 Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 1/5] Add CET xsaves/xrstors related macros and structures Yang Weijiang
                   ` (4 more replies)
  0 siblings, 5 replies; 133+ messages in thread
From: Yang Weijiang @ 2019-02-25 13:18 UTC (permalink / raw)
  To: pbonzini, cdupontd, rkrcmar, qemu-devel, mst; +Cc: Yang Weijiang

Subject: [Qemu-devel][PATCH v3 0/5] This patch-set is to enable Guest
CET support.

Control-flow Enforcement Technology (CET) provides protection against
return/jump-oriented programming (ROP) attacks. To make kvm Guest OS own
the capability, this patch-set is required. It enables CET related CPUID
report, xsaves/xrstors and live-migration etc. in Qemu.

Changelog:

 v3:
 - Add CET MSR save/restore support for live-migration.

 v2:
 - In CPUID.(EAX=d, ECX=1), set return ECX[n] = 0 if bit n corresponds
   to a bit in MSR_IA32_XSS.
 - In CPUID.(EAX=d, ECX=n), set return ECX = 1 if bit n corresponds
   to a bit in MSR_IA32_XSS.
 - Skip Supervisor mode xsave component when calculate User mode
   xave component size in xsave_area_size() and x86_cpu_reset().

Yang Weijiang (5):
  Add CET xsaves/xrstors related macros and structures.
  Add CET SHSTK and IBT CPUID feature-word definitions.
  Add hepler functions for CPUID xsave area size calculation.
  Report CPUID xsave area support for CET.
  Add CET MSR save/restore support for migration

 target/i386/cpu.c     |  73 ++++++++++++++++++++++++++++--
 target/i386/cpu.h     |  48 +++++++++++++++++++-
 target/i386/kvm.c     |  27 ++++++++++++
 target/i386/machine.c | 100 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 244 insertions(+), 4 deletions(-)

-- 
2.17.1

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

* [Qemu-devel] [PATCH v3 1/5] Add CET xsaves/xrstors related macros and structures.
  2019-02-25 13:18 [Qemu-devel] (no subject) Yang Weijiang
@ 2019-02-25 13:18 ` Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 2/5] Add CET SHSTK and IBT CPUID feature-word definitions Yang Weijiang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 133+ messages in thread
From: Yang Weijiang @ 2019-02-25 13:18 UTC (permalink / raw)
  To: pbonzini, cdupontd, rkrcmar, qemu-devel, mst; +Cc: Yang Weijiang, Zhang Yi

CET protection in user mode and kernel mode relies on
specific MSRs, these MSRs' contents are automatically
saved/restored by xsaves/xrstors instructions.

Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/cpu.h | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 9c52d0cbeb..f3f724d8e6 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -469,6 +469,9 @@ typedef enum X86Seg {
 #define XSTATE_ZMM_Hi256_BIT            6
 #define XSTATE_Hi16_ZMM_BIT             7
 #define XSTATE_PKRU_BIT                 9
+#define XSTATE_RESERVED_BIT             10
+#define XSTATE_CET_U_BIT                11
+#define XSTATE_CET_S_BIT                12
 
 #define XSTATE_FP_MASK                  (1ULL << XSTATE_FP_BIT)
 #define XSTATE_SSE_MASK                 (1ULL << XSTATE_SSE_BIT)
@@ -479,6 +482,19 @@ typedef enum X86Seg {
 #define XSTATE_ZMM_Hi256_MASK           (1ULL << XSTATE_ZMM_Hi256_BIT)
 #define XSTATE_Hi16_ZMM_MASK            (1ULL << XSTATE_Hi16_ZMM_BIT)
 #define XSTATE_PKRU_MASK                (1ULL << XSTATE_PKRU_BIT)
+#define XSTATE_RESERVED_MASK            (1ULL << XSTATE_RESERVED_BIT)
+#define XSTATE_CET_U_MASK               (1ULL << XSTATE_CET_U_BIT)
+#define XSTATE_CET_S_MASK               (1ULL << XSTATE_CET_S_BIT)
+
+/* CPUID feature bits available in XCR0 */
+#define CPUID_XSTATE_USER_MASK  (XSTATE_FP_MASK | XSTATE_SSE_MASK \
+                                | XSTATE_YMM_MASK | XSTATE_BNDREGS_MASK \
+                                | XSTATE_BNDCSR_MASK | XSTATE_OPMASK_MASK \
+                                | XSTATE_ZMM_Hi256_MASK \
+                                | XSTATE_Hi16_ZMM_MASK | XSTATE_PKRU_MASK)
+
+/* CPUID feature bits available in XSS */
+#define CPUID_XSTATE_KERNEL_MASK    (XSTATE_CET_U_MASK | XSTATE_CET_S_MASK)
 
 /* CPUID feature words */
 typedef enum FeatureWord {
@@ -503,6 +519,8 @@ typedef enum FeatureWord {
     FEAT_XSAVE_COMP_LO, /* CPUID[EAX=0xd,ECX=0].EAX */
     FEAT_XSAVE_COMP_HI, /* CPUID[EAX=0xd,ECX=0].EDX */
     FEAT_ARCH_CAPABILITIES,
+    FEAT_XSAVE_SV_LO,   /* CPUID[EAX=0xd,ECX=1].ECX */
+    FEAT_XSAVE_SV_HI,   /* CPUID[EAX=0xd,ECX=1].EDX */
     FEATURE_WORDS,
 } FeatureWord;
 
@@ -687,7 +705,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_7_0_ECX_LA57     (1U << 16)
 #define CPUID_7_0_ECX_RDPID    (1U << 22)
 #define CPUID_7_0_ECX_CLDEMOTE (1U << 25)  /* CLDEMOTE Instruction */
-
+#define CPUID_7_0_ECX_CET_SHSTK     (1U << 7)  /* CET SHSTK feature bit */
 #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2) /* AVX512 Neural Network Instructions */
 #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
 #define CPUID_7_0_EDX_PCONFIG (1U << 18)       /* Platform Configuration */
@@ -1021,6 +1039,19 @@ typedef struct XSavePKRU {
     uint32_t padding;
 } XSavePKRU;
 
+/* Ext. save area 11: User mode CET state */
+typedef struct XSaveCETU {
+    uint64_t u_cet;
+    uint64_t user_ssp;
+} XSaveCETU;
+
+/* Ext. save area 12: Supervisor mode CET state */
+typedef struct XSaveCETS {
+    uint64_t kernel_ssp;
+    uint64_t pl1_ssp;
+    uint64_t pl2_ssp;
+} XSaveCETS;
+
 typedef struct X86XSaveArea {
     X86LegacyXSaveArea legacy;
     X86XSaveHeader header;
@@ -1039,6 +1070,9 @@ typedef struct X86XSaveArea {
     XSaveHi16_ZMM hi16_zmm_state;
     /* PKRU State: */
     XSavePKRU pkru_state;
+    /* CET State: */
+    XSaveCETU cet_u;
+    XSaveCETS cet_s;
 } X86XSaveArea;
 
 QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, avx_state) != 0x240);
-- 
2.17.1

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

* [Qemu-devel] [PATCH v3 2/5] Add CET SHSTK and IBT CPUID feature-word definitions.
  2019-02-25 13:18 [Qemu-devel] (no subject) Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 1/5] Add CET xsaves/xrstors related macros and structures Yang Weijiang
@ 2019-02-25 13:18 ` Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 3/5] Add hepler functions for CPUID xsave area size calculation Yang Weijiang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 133+ messages in thread
From: Yang Weijiang @ 2019-02-25 13:18 UTC (permalink / raw)
  To: pbonzini, cdupontd, rkrcmar, qemu-devel, mst; +Cc: Yang Weijiang, Zhang Yi

XSS[bit 11] and XSS[bit 12] correspond to CET
user mode area and supervisor mode area respectively.

Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/cpu.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index f81d35e1f9..f6c7bdf6fe 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1018,7 +1018,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
         .type = CPUID_FEATURE_WORD,
         .feat_names = {
             NULL, "avx512vbmi", "umip", "pku",
-            NULL /* ospke */, NULL, "avx512vbmi2", NULL,
+            NULL /* ospke */, NULL, "avx512vbmi2", "shstk",
             "gfni", "vaes", "vpclmulqdq", "avx512vnni",
             "avx512bitalg", NULL, "avx512-vpopcntdq", NULL,
             "la57", NULL, NULL, NULL,
@@ -1041,7 +1041,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
             NULL, NULL, NULL, NULL,
             NULL, NULL, NULL, NULL,
             NULL, NULL, "pconfig", NULL,
-            NULL, NULL, NULL, NULL,
+            "ibt", NULL, NULL, NULL,
             NULL, NULL, "spec-ctrl", NULL,
             NULL, "arch-capabilities", NULL, "ssbd",
         },
@@ -1162,6 +1162,25 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
             }
         },
     },
+    /* Below are CET supervisor xsave features */
+    [FEAT_XSAVE_SV_LO] = {
+        .type = CPUID_FEATURE_WORD,
+        .cpuid = {
+            .eax = 0xD,
+            .needs_ecx = true,
+            .ecx = 1,
+            .reg = R_ECX,
+        },
+    },
+    [FEAT_XSAVE_SV_HI] = {
+        .type = CPUID_FEATURE_WORD,
+        .cpuid = {
+            .eax = 0xD,
+            .needs_ecx = true,
+            .ecx = 1,
+            .reg = R_EDX
+        },
+    }
 };
 
 typedef struct X86RegisterInfo32 {
@@ -1233,6 +1252,14 @@ static const ExtSaveArea x86_ext_save_areas[] = {
           { .feature = FEAT_7_0_ECX, .bits = CPUID_7_0_ECX_PKU,
             .offset = offsetof(X86XSaveArea, pkru_state),
             .size = sizeof(XSavePKRU) },
+    [XSTATE_CET_U_BIT] = {
+            .feature = FEAT_7_0_ECX, .bits = CPUID_7_0_ECX_CET_SHSTK,
+            .offset = 0 /*supervisor mode component, offset = 0 */,
+            .size = sizeof(XSaveCETU) },
+    [XSTATE_CET_S_BIT] = {
+            .feature = FEAT_7_0_ECX, .bits = CPUID_7_0_ECX_CET_SHSTK,
+            .offset = 0 /*supervisor mode component, offset = 0 */,
+            .size = sizeof(XSaveCETS) },
 };
 
 static uint32_t xsave_area_size(uint64_t mask)
@@ -1243,6 +1270,9 @@ static uint32_t xsave_area_size(uint64_t mask)
     for (i = 0; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
         const ExtSaveArea *esa = &x86_ext_save_areas[i];
         if ((mask >> i) & 1) {
+            if (i >= 2 && !esa->offset) {
+                continue;
+            }
             ret = MAX(ret, esa->offset + esa->size);
         }
     }
@@ -4657,6 +4687,9 @@ static void x86_cpu_reset(CPUState *s)
     }
     for (i = 2; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
         const ExtSaveArea *esa = &x86_ext_save_areas[i];
+        if (!esa->offset) {
+            continue;
+        }
         if (env->features[esa->feature] & esa->bits) {
             xcr0 |= 1ull << i;
         }
-- 
2.17.1

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

* [Qemu-devel] [PATCH v3 3/5] Add hepler functions for CPUID xsave area size calculation.
  2019-02-25 13:18 [Qemu-devel] (no subject) Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 1/5] Add CET xsaves/xrstors related macros and structures Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 2/5] Add CET SHSTK and IBT CPUID feature-word definitions Yang Weijiang
@ 2019-02-25 13:18 ` Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 4/5] Report CPUID xsave area support for CET Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 5/5] Add CET MSR save/restore support for migration Yang Weijiang
  4 siblings, 0 replies; 133+ messages in thread
From: Yang Weijiang @ 2019-02-25 13:18 UTC (permalink / raw)
  To: pbonzini, cdupontd, rkrcmar, qemu-devel, mst; +Cc: Yang Weijiang, Zhang Yi

These functions are called when return CPUID xsave area
size information.

Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/cpu.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index f6c7bdf6fe..d8c36e0f2f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1284,12 +1284,34 @@ static inline bool accel_uses_host_cpuid(void)
     return kvm_enabled() || hvf_enabled();
 }
 
+static uint32_t xsave_area_size_compacted(uint64_t mask)
+{
+    int i;
+    uint64_t ret = 0;
+    uint32_t offset;
+
+    for (i = 0; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
+        const ExtSaveArea *esa = &x86_ext_save_areas[i];
+        offset = i >= 2 ? ret : esa->offset;
+        if ((mask >> i) & 1) {
+            ret = MAX(ret, offset + esa->size);
+        }
+    }
+    return ret;
+}
+
 static inline uint64_t x86_cpu_xsave_components(X86CPU *cpu)
 {
     return ((uint64_t)cpu->env.features[FEAT_XSAVE_COMP_HI]) << 32 |
            cpu->env.features[FEAT_XSAVE_COMP_LO];
 }
 
+static inline uint64_t x86_cpu_xsave_sv_components(X86CPU *cpu)
+{
+    return ((uint64_t)cpu->env.features[FEAT_XSAVE_SV_HI]) << 32 |
+           cpu->env.features[FEAT_XSAVE_SV_LO];
+}
+
 const char *get_register_name_32(unsigned int reg)
 {
     if (reg >= CPU_NB_REGS32) {
@@ -4919,8 +4941,10 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
         }
     }
 
-    env->features[FEAT_XSAVE_COMP_LO] = mask;
+    env->features[FEAT_XSAVE_COMP_LO] = mask & CPUID_XSTATE_USER_MASK;
     env->features[FEAT_XSAVE_COMP_HI] = mask >> 32;
+    env->features[FEAT_XSAVE_SV_LO] = mask & CPUID_XSTATE_KERNEL_MASK;
+    env->features[FEAT_XSAVE_SV_HI] = mask >> 32;
 }
 
 /***** Steps involved on loading and filtering CPUID data
-- 
2.17.1

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

* [Qemu-devel] [PATCH v3 4/5] Report CPUID xsave area support for CET.
  2019-02-25 13:18 [Qemu-devel] (no subject) Yang Weijiang
                   ` (2 preceding siblings ...)
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 3/5] Add hepler functions for CPUID xsave area size calculation Yang Weijiang
@ 2019-02-25 13:18 ` Yang Weijiang
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 5/5] Add CET MSR save/restore support for migration Yang Weijiang
  4 siblings, 0 replies; 133+ messages in thread
From: Yang Weijiang @ 2019-02-25 13:18 UTC (permalink / raw)
  To: pbonzini, cdupontd, rkrcmar, qemu-devel, mst; +Cc: Yang Weijiang, Zhang Yi

CPUID bit definition as below:
CPUID.(EAX=d, ECX=1):ECX.CET_U(bit 11): user mode state
CPUID.(EAX=d, ECX=1):ECX.CET_S(bit 12): kernel mode state

Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/cpu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index d8c36e0f2f..15e2d5e009 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4399,12 +4399,22 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
             *ebx = xsave_area_size(env->xcr0);
         } else if (count == 1) {
             *eax = env->features[FEAT_XSAVE];
+            *ecx = env->features[FEAT_XSAVE_SV_LO];
+            *edx = env->features[FEAT_XSAVE_SV_HI];
+            *ebx = xsave_area_size_compacted(x86_cpu_xsave_components(cpu) |
+                    x86_cpu_xsave_sv_components(cpu));
         } else if (count < ARRAY_SIZE(x86_ext_save_areas)) {
             if ((x86_cpu_xsave_components(cpu) >> count) & 1) {
                 const ExtSaveArea *esa = &x86_ext_save_areas[count];
                 *eax = esa->size;
                 *ebx = esa->offset;
             }
+            if ((x86_cpu_xsave_sv_components(cpu) >> count) & 1) {
+                const ExtSaveArea *esa_sv = &x86_ext_save_areas[count];
+                *eax = esa_sv->size;
+                *ebx = 0;
+                *ecx = 1;
+            }
         }
         break;
     }
-- 
2.17.1

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

* [Qemu-devel] [PATCH v3 5/5] Add CET MSR save/restore support for migration
  2019-02-25 13:18 [Qemu-devel] (no subject) Yang Weijiang
                   ` (3 preceding siblings ...)
  2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 4/5] Report CPUID xsave area support for CET Yang Weijiang
@ 2019-02-25 13:18 ` Yang Weijiang
  4 siblings, 0 replies; 133+ messages in thread
From: Yang Weijiang @ 2019-02-25 13:18 UTC (permalink / raw)
  To: pbonzini, cdupontd, rkrcmar, qemu-devel, mst; +Cc: Yang Weijiang

To support features such as live-migration,
CET runtime MSRs need to be saved in source machine and
restored on destination machine, this patch is to save
and restore CET_U, CET_S, PL0_SSP, PL3_SSP and SSP_TABL_ADDR
MSRs.

Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 target/i386/cpu.h     |  12 +++++
 target/i386/kvm.c     |  33 ++++++++++++++
 target/i386/machine.c | 100 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 145 insertions(+)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index f3f724d8e6..f350684895 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -460,6 +460,12 @@ typedef enum X86Seg {
 #define MSR_IA32_BNDCFGS                0x00000d90
 #define MSR_IA32_XSS                    0x00000da0
 
+#define MSR_IA32_U_CET                  0x6a0
+#define MSR_IA32_S_CET                  0x6a2
+#define MSR_IA32_PL0_SSP                0x6a4
+#define MSR_IA32_PL3_SSP                0x6a7
+#define MSR_IA32_INTR_SSP_TABL          0x6a8
+
 #define XSTATE_FP_BIT                   0
 #define XSTATE_SSE_BIT                  1
 #define XSTATE_YMM_BIT                  2
@@ -1325,6 +1331,12 @@ typedef struct CPUX86State {
 
     uintptr_t retaddr;
 
+    uint64_t u_cet;
+    uint64_t s_cet;
+    uint64_t pl0_ssp;
+    uint64_t pl3_ssp;
+    uint64_t ssp_tabl_addr;
+
     /* Fields up to this point are cleared by a CPU reset */
     struct {} end_reset_fields;
 
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index f524e7d929..2ab3c977a4 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -63,6 +63,8 @@
 /* A 4096-byte buffer can hold the 8-byte kvm_msrs header, plus
  * 255 kvm_msr_entry structs */
 #define MSR_BUF_SIZE 4096
+#define HAS_CET_CAP(env)  (env->features[FEAT_7_0_ECX] & 0x80 || \
+                           env->features[FEAT_7_0_EDX] & 0x100000)
 
 const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
     KVM_CAP_INFO(SET_TSS_ADDR),
@@ -2197,6 +2199,14 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         }
     }
 
+    if (HAS_CET_CAP(env)) {
+        kvm_msr_entry_add(cpu, MSR_IA32_U_CET, env->u_cet);
+        kvm_msr_entry_add(cpu, MSR_IA32_S_CET, env->s_cet);
+        kvm_msr_entry_add(cpu, MSR_IA32_PL0_SSP, env->pl0_ssp);
+        kvm_msr_entry_add(cpu, MSR_IA32_PL3_SSP, env->pl3_ssp);
+        kvm_msr_entry_add(cpu, MSR_IA32_INTR_SSP_TABL, env->ssp_tabl_addr);
+    }
+
     ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
     if (ret < 0) {
         return ret;
@@ -2516,6 +2526,14 @@ static int kvm_get_msrs(X86CPU *cpu)
         }
     }
 
+    if (HAS_CET_CAP(env)) {
+        kvm_msr_entry_add(cpu, MSR_IA32_U_CET, 0);
+        kvm_msr_entry_add(cpu, MSR_IA32_S_CET, 0);
+        kvm_msr_entry_add(cpu, MSR_IA32_PL0_SSP, 0);
+        kvm_msr_entry_add(cpu, MSR_IA32_PL3_SSP, 0);
+        kvm_msr_entry_add(cpu, MSR_IA32_INTR_SSP_TABL, 0);
+    }
+
     ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, cpu->kvm_msr_buf);
     if (ret < 0) {
         return ret;
@@ -2789,6 +2807,21 @@ static int kvm_get_msrs(X86CPU *cpu)
         case MSR_IA32_RTIT_ADDR0_A ... MSR_IA32_RTIT_ADDR3_B:
             env->msr_rtit_addrs[index - MSR_IA32_RTIT_ADDR0_A] = msrs[i].data;
             break;
+        case MSR_IA32_U_CET:
+            env->u_cet = msrs[i].data;
+            break;
+        case MSR_IA32_S_CET:
+            env->s_cet = msrs[i].data;
+            break;
+        case MSR_IA32_PL0_SSP:
+            env->pl0_ssp = msrs[i].data;
+            break;
+        case MSR_IA32_PL3_SSP:
+            env->pl3_ssp = msrs[i].data;
+            break;
+        case MSR_IA32_INTR_SSP_TABL:
+            env->ssp_tabl_addr = msrs[i].data;
+            break;
         }
     }
 
diff --git a/target/i386/machine.c b/target/i386/machine.c
index 225b5d433b..5f8a12ca30 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -810,6 +810,101 @@ static const VMStateDescription vmstate_xss = {
     }
 };
 
+static bool u_cet_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+
+    return env->u_cet != 0;
+}
+
+static const VMStateDescription vmstate_u_cet = {
+    .name = "cpu/u_cet",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = u_cet_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.u_cet, X86CPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static bool s_cet_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+
+    return env->s_cet != 0;
+}
+
+static const VMStateDescription vmstate_s_cet = {
+    .name = "cpu/s_cet",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = s_cet_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.s_cet, X86CPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static bool pl0_ssp_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+
+    return env->pl0_ssp != 0;
+}
+
+static const VMStateDescription vmstate_pl0_ssp = {
+    .name = "cpu/pl0_ssp",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = pl0_ssp_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.pl0_ssp, X86CPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static bool pl3_ssp_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+
+    return env->pl3_ssp != 0;
+}
+
+static const VMStateDescription vmstate_pl3_ssp = {
+    .name = "cpu/pl3_ssp",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = pl3_ssp_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.pl3_ssp, X86CPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static bool ssp_tabl_addr_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+
+    return env->ssp_tabl_addr != 0;
+}
+
+static const VMStateDescription vmstate_ssp_tabl_addr = {
+    .name = "cpu/ssp_tabl_addr",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = ssp_tabl_addr_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.ssp_tabl_addr, X86CPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 #ifdef TARGET_X86_64
 static bool pkru_needed(void *opaque)
 {
@@ -1089,6 +1184,11 @@ VMStateDescription vmstate_x86_cpu = {
         &vmstate_msr_intel_pt,
         &vmstate_msr_virt_ssbd,
         &vmstate_svm_npt,
+        &vmstate_u_cet,
+        &vmstate_s_cet,
+        &vmstate_pl0_ssp,
+        &vmstate_pl3_ssp,
+        &vmstate_ssp_tabl_addr,
         NULL
     }
 };
-- 
2.17.1

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

* [Qemu-devel] (no subject)
@ 2019-01-02  2:02 Yaowei Bai
  0 siblings, 0 replies; 133+ messages in thread
From: Yaowei Bai @ 2019-01-02  2:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: fam, qemu-block, famz, atumball, mchristi, pkalever, pbonzini,
	xiubli, baiyaowei

baiyaowei@cmss.chinamobile.com
Bcc: 
Subject: Re: [Qemu-devel] [PATCH] tcmu: Introduce qemu-tcmu utility
Reply-To: baiyaowei@cmss.chinamobile.com
In-Reply-To: <20190102015321.GA26514@byw>

Add Xiubo.

On Wed, Jan 02, 2019 at 09:53:21AM +0800, Yaowei Bai wrote:
> Ping.
> 
> BTW, it should be update docker image to install glib to fix this.
> 
> On Wed, Dec 26, 2018 at 12:19:48AM -0800, no-reply@patchew.org wrote:
> > Patchew URL: https://patchew.org/QEMU/1545387387-9613-1-git-send-email-baiyaowei@cmss.chinamobile.com/
> > 
> > 
> > 
> > Hi,
> > 
> > This series seems to have some coding style problems. See output below for
> > more information:
> > 
> > Message-id: 1545387387-9613-1-git-send-email-baiyaowei@cmss.chinamobile.com
> > Type: series
> > Subject: [Qemu-devel] [PATCH] tcmu: Introduce qemu-tcmu utility
> > 
> > === TEST SCRIPT BEGIN ===
> > #!/bin/bash
> > 
> > BASE=base
> > n=1
> > total=$(git log --oneline $BASE.. | wc -l)
> > failed=0
> > 
> > git config --local diff.renamelimit 0
> > git config --local diff.renames True
> > git config --local diff.algorithm histogram
> > 
> > commits="$(git log --format=%H --reverse $BASE..)"
> > for c in $commits; do
> >     echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
> >     if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
> >         failed=1
> >         echo
> >     fi
> >     n=$((n+1))
> > done
> > 
> > exit $failed
> > === TEST SCRIPT END ===
> > 
> > Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
> > Switched to a new branch 'test'
> > 52869e1 tcmu: Introduce qemu-tcmu utility
> > 
> > === OUTPUT BEGIN ===
> > Checking PATCH 1/1: tcmu: Introduce qemu-tcmu utility...
> > WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> > #157: 
> > new file mode 100644
> > 
> > ERROR: trailing whitespace
> > #329: FILE: qemu-tcmu.c:51:
> > +"Usage:\n" $
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #466: FILE: qemu-tcmu.c:188:
> > +    /* now when the initialization is (almost) complete, chdir("/")
> > 
> > WARNING: Block comments use a trailing */ on a separate line
> > #467: FILE: qemu-tcmu.c:189:
> > +     * to free any busy filesystems */
> > 
> > ERROR: code indent should never use tabs
> > #525: FILE: tcmu/helper.c:16:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #526: FILE: tcmu/helper.c:17:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #527: FILE: tcmu/helper.c:18:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #529: FILE: tcmu/helper.c:20:
> > +^Iuint8_t buf[36];$
> > 
> > ERROR: code indent should never use tabs
> > #531: FILE: tcmu/helper.c:22:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #533: FILE: tcmu/helper.c:24:
> > +^Ibuf[2] = 0x05; /* SPC-3 */$
> > 
> > ERROR: code indent should never use tabs
> > #534: FILE: tcmu/helper.c:25:
> > +^Ibuf[3] = 0x02; /* response data format */$
> > 
> > ERROR: code indent should never use tabs
> > #536: FILE: tcmu/helper.c:27:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #537: FILE: tcmu/helper.c:28:
> > +^I * A Third-Party Copy (3PC)$
> > 
> > ERROR: code indent should never use tabs
> > #538: FILE: tcmu/helper.c:29:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #539: FILE: tcmu/helper.c:30:
> > +^I * Enable the XCOPY$
> > 
> > ERROR: code indent should never use tabs
> > #540: FILE: tcmu/helper.c:31:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #541: FILE: tcmu/helper.c:32:
> > +^Ibuf[5] = 0x08;$
> > 
> > ERROR: code indent should never use tabs
> > #543: FILE: tcmu/helper.c:34:
> > +^Ibuf[7] = 0x02; /* CmdQue */$
> > 
> > ERROR: code indent should never use tabs
> > #545: FILE: tcmu/helper.c:36:
> > +^Imemcpy(&buf[8], "LIO-ORG ", 8);$
> > 
> > ERROR: code indent should never use tabs
> > #546: FILE: tcmu/helper.c:37:
> > +^Imemset(&buf[16], 0x20, 16);$
> > 
> > ERROR: code indent should never use tabs
> > #547: FILE: tcmu/helper.c:38:
> > +^Imemcpy(&buf[16], "TCMU device", 11);$
> > 
> > ERROR: code indent should never use tabs
> > #548: FILE: tcmu/helper.c:39:
> > +^Imemcpy(&buf[32], "0002", 4);$
> > 
> > ERROR: code indent should never use tabs
> > #549: FILE: tcmu/helper.c:40:
> > +^Ibuf[4] = 31; /* Set additional length to 31 */$
> > 
> > ERROR: code indent should never use tabs
> > #551: FILE: tcmu/helper.c:42:
> > +^Itcmu_memcpy_into_iovec(iovec, iov_cnt, buf, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #552: FILE: tcmu/helper.c:43:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #558: FILE: tcmu/helper.c:49:
> > +^Iif (c >= '0' && c <= '9') {$
> > 
> > ERROR: code indent should never use tabs
> > #559: FILE: tcmu/helper.c:50:
> > +^I^I*val = c - '0';$
> > 
> > ERROR: code indent should never use tabs
> > #560: FILE: tcmu/helper.c:51:
> > +^I^Ireturn true;$
> > 
> > ERROR: code indent should never use tabs
> > #561: FILE: tcmu/helper.c:52:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #562: FILE: tcmu/helper.c:53:
> > +^Iif (c >= 'a' && c <= 'f') {$
> > 
> > ERROR: code indent should never use tabs
> > #563: FILE: tcmu/helper.c:54:
> > +^I^I*val = c - 'a' + 10;$
> > 
> > ERROR: code indent should never use tabs
> > #564: FILE: tcmu/helper.c:55:
> > +^I^Ireturn true;$
> > 
> > ERROR: code indent should never use tabs
> > #565: FILE: tcmu/helper.c:56:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #566: FILE: tcmu/helper.c:57:
> > +^Iif (c >= 'A' && c <= 'F') {$
> > 
> > ERROR: code indent should never use tabs
> > #567: FILE: tcmu/helper.c:58:
> > +^I^I*val = c - 'A' + 10;$
> > 
> > ERROR: code indent should never use tabs
> > #568: FILE: tcmu/helper.c:59:
> > +^I^Ireturn true;$
> > 
> > ERROR: code indent should never use tabs
> > #569: FILE: tcmu/helper.c:60:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #570: FILE: tcmu/helper.c:61:
> > +^Ireturn false;$
> > 
> > ERROR: code indent should never use tabs
> > #574: FILE: tcmu/helper.c:65:
> > +^Istruct tcmu_device *dev,$
> > 
> > ERROR: code indent should never use tabs
> > #575: FILE: tcmu/helper.c:66:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #576: FILE: tcmu/helper.c:67:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #577: FILE: tcmu/helper.c:68:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #579: FILE: tcmu/helper.c:70:
> > +^Iswitch (cdb[2]) {$
> > 
> > ERROR: code indent should never use tabs
> > #580: FILE: tcmu/helper.c:71:
> > +^Icase 0x0: /* Supported VPD pages */$
> > 
> > ERROR: code indent should never use tabs
> > #581: FILE: tcmu/helper.c:72:
> > +^I{$
> > 
> > ERROR: code indent should never use tabs
> > #582: FILE: tcmu/helper.c:73:
> > +^I^Ichar data[16];$
> > 
> > ERROR: code indent should never use tabs
> > #584: FILE: tcmu/helper.c:75:
> > +^I^Imemset(data, 0, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #586: FILE: tcmu/helper.c:77:
> > +^I^I/* data[1] (page code) already 0 */$
> > 
> > ERROR: code indent should never use tabs
> > #587: FILE: tcmu/helper.c:78:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #588: FILE: tcmu/helper.c:79:
> > +^I^I  *  spc4r22 7.7.13 The supported VPD page list shall contain$
> > 
> > WARNING: Block comments should align the * on each line
> > #588: FILE: tcmu/helper.c:79:
> > +               /*
> > +                 *  spc4r22 7.7.13 The supported VPD page list shall contain
> > 
> > ERROR: code indent should never use tabs
> > #589: FILE: tcmu/helper.c:80:
> > +^I^I  *  a list of all VPD page codes (see 7.7) implemented by the$
> > 
> > WARNING: line over 80 characters
> > #590: FILE: tcmu/helper.c:81:
> > +                 *  logical unit in ascending order beginning with page code 00h
> > 
> > ERROR: code indent should never use tabs
> > #590: FILE: tcmu/helper.c:81:
> > +^I^I  *  logical unit in ascending order beginning with page code 00h$
> > 
> > ERROR: code indent should never use tabs
> > #591: FILE: tcmu/helper.c:82:
> > +^I^I  */$
> > 
> > ERROR: code indent should never use tabs
> > #592: FILE: tcmu/helper.c:83:
> > +^I^Idata[4] = 0x00;$
> > 
> > ERROR: code indent should never use tabs
> > #593: FILE: tcmu/helper.c:84:
> > +^I^Idata[5] = 0x80;$
> > 
> > ERROR: code indent should never use tabs
> > #594: FILE: tcmu/helper.c:85:
> > +^I^Idata[6] = 0x83;$
> > 
> > ERROR: code indent should never use tabs
> > #595: FILE: tcmu/helper.c:86:
> > +^I^Idata[7] = 0xb0;$
> > 
> > ERROR: code indent should never use tabs
> > #596: FILE: tcmu/helper.c:87:
> > +^I^Idata[8] = 0xb1;$
> > 
> > ERROR: code indent should never use tabs
> > #597: FILE: tcmu/helper.c:88:
> > +^I^Idata[9] = 0xb2;$
> > 
> > ERROR: code indent should never use tabs
> > #599: FILE: tcmu/helper.c:90:
> > +^I^Idata[3] = 6;$
> > 
> > ERROR: code indent should never use tabs
> > #601: FILE: tcmu/helper.c:92:
> > +^I^Itcmu_memcpy_into_iovec(iovec, iov_cnt, data, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #602: FILE: tcmu/helper.c:93:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #603: FILE: tcmu/helper.c:94:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #604: FILE: tcmu/helper.c:95:
> > +^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #605: FILE: tcmu/helper.c:96:
> > +^Icase 0x80: /* Unit Serial Number */$
> > 
> > ERROR: code indent should never use tabs
> > #606: FILE: tcmu/helper.c:97:
> > +^I{$
> > 
> > ERROR: code indent should never use tabs
> > #607: FILE: tcmu/helper.c:98:
> > +^I^Ichar data[512];$
> > 
> > ERROR: code indent should never use tabs
> > #608: FILE: tcmu/helper.c:99:
> > +^I^Ichar *wwn;$
> > 
> > ERROR: code indent should never use tabs
> > #609: FILE: tcmu/helper.c:100:
> > +^I^Iuint32_t len;$
> > 
> > ERROR: code indent should never use tabs
> > #611: FILE: tcmu/helper.c:102:
> > +^I^Imemset(data, 0, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #613: FILE: tcmu/helper.c:104:
> > +^I^Idata[1] = 0x80;$
> > 
> > ERROR: code indent should never use tabs
> > #615: FILE: tcmu/helper.c:106:
> > +^I^Iwwn = tcmu_cfgfs_dev_get_wwn(dev);$
> > 
> > ERROR: code indent should never use tabs
> > #616: FILE: tcmu/helper.c:107:
> > +^I^Iif (!wwn)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #616: FILE: tcmu/helper.c:107:
> > +               if (!wwn)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #617: FILE: tcmu/helper.c:108:
> > +^I^I^Ireturn TCMU_STS_HW_ERR;$
> > 
> > ERROR: code indent should never use tabs
> > #619: FILE: tcmu/helper.c:110:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #620: FILE: tcmu/helper.c:111:
> > +^I^I * The maximum length of the unit_serial has limited$
> > 
> > ERROR: code indent should never use tabs
> > #621: FILE: tcmu/helper.c:112:
> > +^I^I * to 254 Bytes in kernel, so here limit to 256 Bytes$
> > 
> > ERROR: code indent should never use tabs
> > #622: FILE: tcmu/helper.c:113:
> > +^I^I * will be enough.$
> > 
> > ERROR: code indent should never use tabs
> > #623: FILE: tcmu/helper.c:114:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #624: FILE: tcmu/helper.c:115:
> > +^I^Ilen = snprintf(&data[4], 256, "%s", wwn);$
> > 
> > ERROR: code indent should never use tabs
> > #625: FILE: tcmu/helper.c:116:
> > +^I^Idata[3] = len + 1;$
> > 
> > ERROR: code indent should never use tabs
> > #627: FILE: tcmu/helper.c:118:
> > +^I^Itcmu_memcpy_into_iovec(iovec, iov_cnt, data, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #629: FILE: tcmu/helper.c:120:
> > +^I^Ifree(wwn);$
> > 
> > ERROR: code indent should never use tabs
> > #630: FILE: tcmu/helper.c:121:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #631: FILE: tcmu/helper.c:122:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #632: FILE: tcmu/helper.c:123:
> > +^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #633: FILE: tcmu/helper.c:124:
> > +^Icase 0x83: /* Device identification */$
> > 
> > ERROR: code indent should never use tabs
> > #634: FILE: tcmu/helper.c:125:
> > +^I{$
> > 
> > ERROR: code indent should never use tabs
> > #635: FILE: tcmu/helper.c:126:
> > +^I^Ichar data[512];$
> > 
> > ERROR: code indent should never use tabs
> > #636: FILE: tcmu/helper.c:127:
> > +^I^Ichar *ptr, *p, *wwn;$
> > 
> > ERROR: code indent should never use tabs
> > #637: FILE: tcmu/helper.c:128:
> > +^I^Isize_t len, used = 0;$
> > 
> > ERROR: code indent should never use tabs
> > #638: FILE: tcmu/helper.c:129:
> > +^I^Iuint16_t *tot_len = (uint16_t*) &data[2];$
> > 
> > ERROR: "(foo*)" should be "(foo *)"
> > #638: FILE: tcmu/helper.c:129:
> > +               uint16_t *tot_len = (uint16_t*) &data[2];
> > 
> > ERROR: code indent should never use tabs
> > #639: FILE: tcmu/helper.c:130:
> > +^I^Ibool next;$
> > 
> > ERROR: code indent should never use tabs
> > #640: FILE: tcmu/helper.c:131:
> > +^I^Iint i;$
> > 
> > ERROR: code indent should never use tabs
> > #642: FILE: tcmu/helper.c:133:
> > +^I^Imemset(data, 0, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #644: FILE: tcmu/helper.c:135:
> > +^I^Idata[1] = 0x83;$
> > 
> > ERROR: code indent should never use tabs
> > #646: FILE: tcmu/helper.c:137:
> > +^I^Iwwn = tcmu_cfgfs_dev_get_wwn(dev);$
> > 
> > ERROR: code indent should never use tabs
> > #647: FILE: tcmu/helper.c:138:
> > +^I^Iif (!wwn)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #647: FILE: tcmu/helper.c:138:
> > +               if (!wwn)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #648: FILE: tcmu/helper.c:139:
> > +^I^I^Ireturn TCMU_STS_HW_ERR;$
> > 
> > ERROR: code indent should never use tabs
> > #650: FILE: tcmu/helper.c:141:
> > +^I^Iptr = &data[4];$
> > 
> > ERROR: code indent should never use tabs
> > #652: FILE: tcmu/helper.c:143:
> > +^I^I/* 1/5: T10 Vendor id */$
> > 
> > ERROR: code indent should never use tabs
> > #653: FILE: tcmu/helper.c:144:
> > +^I^Iptr[0] = 2; /* code set: ASCII */$
> > 
> > ERROR: code indent should never use tabs
> > #654: FILE: tcmu/helper.c:145:
> > +^I^Iptr[1] = 1; /* identifier: T10 vendor id */$
> > 
> > ERROR: code indent should never use tabs
> > #655: FILE: tcmu/helper.c:146:
> > +^I^Imemcpy(&ptr[4], "LIO-ORG ", 8);$
> > 
> > ERROR: code indent should never use tabs
> > #656: FILE: tcmu/helper.c:147:
> > +^I^Ilen = snprintf(&ptr[12], sizeof(data) - 16, "%s", wwn);$
> > 
> > ERROR: code indent should never use tabs
> > #658: FILE: tcmu/helper.c:149:
> > +^I^Iptr[3] = 8 + len + 1;$
> > 
> > ERROR: code indent should never use tabs
> > #659: FILE: tcmu/helper.c:150:
> > +^I^Iused += (uint8_t)ptr[3] + 4;$
> > 
> > ERROR: code indent should never use tabs
> > #660: FILE: tcmu/helper.c:151:
> > +^I^Iptr += used;$
> > 
> > ERROR: code indent should never use tabs
> > #662: FILE: tcmu/helper.c:153:
> > +^I^I/* 2/5: NAA binary */$
> > 
> > ERROR: code indent should never use tabs
> > #663: FILE: tcmu/helper.c:154:
> > +^I^Iptr[0] = 1; /* code set: binary */$
> > 
> > ERROR: code indent should never use tabs
> > #664: FILE: tcmu/helper.c:155:
> > +^I^Iptr[1] = 3; /* identifier: NAA */$
> > 
> > WARNING: line over 80 characters
> > #665: FILE: tcmu/helper.c:156:
> > +               ptr[3] = 16; /* body length for naa registered extended format */
> > 
> > ERROR: code indent should never use tabs
> > #665: FILE: tcmu/helper.c:156:
> > +^I^Iptr[3] = 16; /* body length for naa registered extended format */$
> > 
> > ERROR: code indent should never use tabs
> > #667: FILE: tcmu/helper.c:158:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #668: FILE: tcmu/helper.c:159:
> > +^I^I * Set type 6 and use OpenFabrics IEEE Company ID: 00 14 05$
> > 
> > ERROR: code indent should never use tabs
> > #669: FILE: tcmu/helper.c:160:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #670: FILE: tcmu/helper.c:161:
> > +^I^Iptr[4] = 0x60;$
> > 
> > ERROR: code indent should never use tabs
> > #671: FILE: tcmu/helper.c:162:
> > +^I^Iptr[5] = 0x01;$
> > 
> > ERROR: code indent should never use tabs
> > #672: FILE: tcmu/helper.c:163:
> > +^I^Iptr[6] = 0x40;$
> > 
> > ERROR: code indent should never use tabs
> > #673: FILE: tcmu/helper.c:164:
> > +^I^Iptr[7] = 0x50;$
> > 
> > ERROR: code indent should never use tabs
> > #675: FILE: tcmu/helper.c:166:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #676: FILE: tcmu/helper.c:167:
> > +^I^I * Fill in the rest with a binary representation of WWN$
> > 
> > ERROR: code indent should never use tabs
> > #677: FILE: tcmu/helper.c:168:
> > +^I^I *$
> > 
> > ERROR: code indent should never use tabs
> > #678: FILE: tcmu/helper.c:169:
> > +^I^I * This implementation only uses a nibble out of every byte of$
> > 
> > ERROR: code indent should never use tabs
> > #679: FILE: tcmu/helper.c:170:
> > +^I^I * WWN, but this is what the kernel does, and it's nice for our$
> > 
> > ERROR: code indent should never use tabs
> > #680: FILE: tcmu/helper.c:171:
> > +^I^I * values to match.$
> > 
> > ERROR: code indent should never use tabs
> > #681: FILE: tcmu/helper.c:172:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #682: FILE: tcmu/helper.c:173:
> > +^I^Inext = true;$
> > 
> > ERROR: code indent should never use tabs
> > #683: FILE: tcmu/helper.c:174:
> > +^I^Ifor (p = wwn, i = 7; *p && i < 20; p++) {$
> > 
> > ERROR: code indent should never use tabs
> > #684: FILE: tcmu/helper.c:175:
> > +^I^I^Iuint8_t val;$
> > 
> > ERROR: code indent should never use tabs
> > #686: FILE: tcmu/helper.c:177:
> > +^I^I^Iif (!char_to_hex(&val, *p))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #686: FILE: tcmu/helper.c:177:
> > +                       if (!char_to_hex(&val, *p))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #687: FILE: tcmu/helper.c:178:
> > +^I^I^I^Icontinue;$
> > 
> > ERROR: code indent should never use tabs
> > #689: FILE: tcmu/helper.c:180:
> > +^I^I^Iif (next) {$
> > 
> > ERROR: code indent should never use tabs
> > #690: FILE: tcmu/helper.c:181:
> > +^I^I^I^Inext = false;$
> > 
> > ERROR: code indent should never use tabs
> > #691: FILE: tcmu/helper.c:182:
> > +^I^I^I^Iptr[i++] |= val;$
> > 
> > ERROR: code indent should never use tabs
> > #692: FILE: tcmu/helper.c:183:
> > +^I^I^I} else {$
> > 
> > ERROR: code indent should never use tabs
> > #693: FILE: tcmu/helper.c:184:
> > +^I^I^I^Inext = true;$
> > 
> > ERROR: code indent should never use tabs
> > #694: FILE: tcmu/helper.c:185:
> > +^I^I^I^Iptr[i] = val << 4;$
> > 
> > ERROR: code indent should never use tabs
> > #695: FILE: tcmu/helper.c:186:
> > +^I^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #696: FILE: tcmu/helper.c:187:
> > +^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #698: FILE: tcmu/helper.c:189:
> > +^I^Iused += 20;$
> > 
> > ERROR: code indent should never use tabs
> > #699: FILE: tcmu/helper.c:190:
> > +^I^Iptr += 20;$
> > 
> > ERROR: code indent should never use tabs
> > #701: FILE: tcmu/helper.c:192:
> > +^I^I/* 3/6: Vendor specific */$
> > 
> > ERROR: code indent should never use tabs
> > #702: FILE: tcmu/helper.c:193:
> > +^I^Iptr[0] = 2; /* code set: ASCII */$
> > 
> > ERROR: code indent should never use tabs
> > #703: FILE: tcmu/helper.c:194:
> > +^I^Iptr[1] = 0; /* identifier: vendor-specific */$
> > 
> > ERROR: line over 90 characters
> > #705: FILE: tcmu/helper.c:196:
> > +               len = snprintf(&ptr[4], sizeof(data) - used - 4, "%s", tcmu_dev_get_cfgstring(dev));
> > 
> > ERROR: code indent should never use tabs
> > #705: FILE: tcmu/helper.c:196:
> > +^I^Ilen = snprintf(&ptr[4], sizeof(data) - used - 4, "%s", tcmu_dev_get_cfgstring(dev));$
> > 
> > ERROR: code indent should never use tabs
> > #706: FILE: tcmu/helper.c:197:
> > +^I^Iptr[3] = len + 1;$
> > 
> > ERROR: code indent should never use tabs
> > #708: FILE: tcmu/helper.c:199:
> > +^I^Iused += (uint8_t)ptr[3] + 4;$
> > 
> > ERROR: code indent should never use tabs
> > #709: FILE: tcmu/helper.c:200:
> > +^I^Iptr += (uint8_t)ptr[3] + 4;$
> > 
> > ERROR: code indent should never use tabs
> > #711: FILE: tcmu/helper.c:202:
> > +^I^I/* Done with descriptor list */$
> > 
> > ERROR: code indent should never use tabs
> > #713: FILE: tcmu/helper.c:204:
> > +^I^I*tot_len = htobe16(used);$
> > 
> > ERROR: code indent should never use tabs
> > #715: FILE: tcmu/helper.c:206:
> > +^I^Itcmu_memcpy_into_iovec(iovec, iov_cnt, data, used + 4);$
> > 
> > ERROR: code indent should never use tabs
> > #717: FILE: tcmu/helper.c:208:
> > +^I^Ifree(wwn);$
> > 
> > ERROR: code indent should never use tabs
> > #718: FILE: tcmu/helper.c:209:
> > +^I^Iwwn = NULL;$
> > 
> > ERROR: code indent should never use tabs
> > #720: FILE: tcmu/helper.c:211:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #721: FILE: tcmu/helper.c:212:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #722: FILE: tcmu/helper.c:213:
> > +^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #723: FILE: tcmu/helper.c:214:
> > +^Icase 0xb0: /* Block Limits */$
> > 
> > ERROR: code indent should never use tabs
> > #724: FILE: tcmu/helper.c:215:
> > +^I{$
> > 
> > ERROR: code indent should never use tabs
> > #725: FILE: tcmu/helper.c:216:
> > +^I^Ichar data[64];$
> > 
> > ERROR: code indent should never use tabs
> > #726: FILE: tcmu/helper.c:217:
> > +^I^Iuint32_t max_xfer_length;$
> > 
> > ERROR: code indent should never use tabs
> > #727: FILE: tcmu/helper.c:218:
> > +^I^Iuint16_t val16;$
> > 
> > ERROR: code indent should never use tabs
> > #728: FILE: tcmu/helper.c:219:
> > +^I^Iuint32_t val32;$
> > 
> > ERROR: code indent should never use tabs
> > #730: FILE: tcmu/helper.c:221:
> > +^I^Imemset(data, 0, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #732: FILE: tcmu/helper.c:223:
> > +^I^Idata[1] = 0xb0;$
> > 
> > ERROR: code indent should never use tabs
> > #734: FILE: tcmu/helper.c:225:
> > +^I^Ival16 = htobe16(0x3c);$
> > 
> > ERROR: code indent should never use tabs
> > #735: FILE: tcmu/helper.c:226:
> > +^I^Imemcpy(&data[2], &val16, 2);$
> > 
> > ERROR: code indent should never use tabs
> > #737: FILE: tcmu/helper.c:228:
> > +^I^I/* WSNZ = 1: the device server won't support a value of zero$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #737: FILE: tcmu/helper.c:228:
> > +               /* WSNZ = 1: the device server won't support a value of zero
> > 
> > ERROR: code indent should never use tabs
> > #738: FILE: tcmu/helper.c:229:
> > +^I^I * in the NUMBER OF LOGICAL BLOCKS field in the WRITE SAME$
> > 
> > ERROR: code indent should never use tabs
> > #739: FILE: tcmu/helper.c:230:
> > +^I^I * command CDBs$
> > 
> > ERROR: code indent should never use tabs
> > #740: FILE: tcmu/helper.c:231:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #741: FILE: tcmu/helper.c:232:
> > +^I^Idata[4] = 0x01;$
> > 
> > ERROR: code indent should never use tabs
> > #743: FILE: tcmu/helper.c:234:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #744: FILE: tcmu/helper.c:235:
> > +^I^I * Daemons like runner may override the user requested$
> > 
> > ERROR: code indent should never use tabs
> > #745: FILE: tcmu/helper.c:236:
> > +^I^I * value due to device specific limits.$
> > 
> > ERROR: code indent should never use tabs
> > #746: FILE: tcmu/helper.c:237:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #747: FILE: tcmu/helper.c:238:
> > +^I^Imax_xfer_length = tcmu_dev_get_max_xfer_len(dev);$
> > 
> > ERROR: code indent should never use tabs
> > #749: FILE: tcmu/helper.c:240:
> > +^I^Ival32 = htobe32(max_xfer_length);$
> > 
> > ERROR: code indent should never use tabs
> > #750: FILE: tcmu/helper.c:241:
> > +^I^I/* Max xfer length */$
> > 
> > ERROR: code indent should never use tabs
> > #751: FILE: tcmu/helper.c:242:
> > +^I^Imemcpy(&data[8], &val32, 4);$
> > 
> > ERROR: code indent should never use tabs
> > #752: FILE: tcmu/helper.c:243:
> > +^I^I/* Optimal xfer length */$
> > 
> > ERROR: code indent should never use tabs
> > #753: FILE: tcmu/helper.c:244:
> > +^I^Imemcpy(&data[12], &val32, 4);$
> > 
> > ERROR: code indent should never use tabs
> > #755: FILE: tcmu/helper.c:246:
> > +^I^Itcmu_memcpy_into_iovec(iovec, iov_cnt, data, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #757: FILE: tcmu/helper.c:248:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #758: FILE: tcmu/helper.c:249:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #759: FILE: tcmu/helper.c:250:
> > +^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #760: FILE: tcmu/helper.c:251:
> > +^Icase 0xb1: /* Block Device Characteristics VPD page */$
> > 
> > ERROR: code indent should never use tabs
> > #761: FILE: tcmu/helper.c:252:
> > +^I{$
> > 
> > ERROR: code indent should never use tabs
> > #762: FILE: tcmu/helper.c:253:
> > +^I^Ichar data[64];$
> > 
> > ERROR: code indent should never use tabs
> > #763: FILE: tcmu/helper.c:254:
> > +^I^Iuint16_t val16;$
> > 
> > ERROR: code indent should never use tabs
> > #765: FILE: tcmu/helper.c:256:
> > +^I^Imemset(data, 0, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #767: FILE: tcmu/helper.c:258:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #768: FILE: tcmu/helper.c:259:
> > +^I^I * From spc-5 Revision 14, section 6.7.2 Standard INQUIRY data$
> > 
> > ERROR: code indent should never use tabs
> > #769: FILE: tcmu/helper.c:260:
> > +^I^I * set the devive type to Direct access block device.$
> > 
> > ERROR: code indent should never use tabs
> > #770: FILE: tcmu/helper.c:261:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #771: FILE: tcmu/helper.c:262:
> > +^I^Idata[0] = 0x00;$
> > 
> > ERROR: code indent should never use tabs
> > #773: FILE: tcmu/helper.c:264:
> > +^I^I/* PAGE CODE (B1h) */$
> > 
> > ERROR: code indent should never use tabs
> > #774: FILE: tcmu/helper.c:265:
> > +^I^Idata[1] = 0xb1;$
> > 
> > ERROR: code indent should never use tabs
> > #776: FILE: tcmu/helper.c:267:
> > +^I^I/* PAGE LENGTH (003Ch)*/$
> > 
> > ERROR: code indent should never use tabs
> > #777: FILE: tcmu/helper.c:268:
> > +^I^Ival16 = htobe16(0x003c);$
> > 
> > ERROR: code indent should never use tabs
> > #778: FILE: tcmu/helper.c:269:
> > +^I^Imemcpy(&data[2], &val16, 2);$
> > 
> > ERROR: code indent should never use tabs
> > #780: FILE: tcmu/helper.c:271:
> > +^I^Iif (tcmu_dev_get_solid_state_media(dev)) {$
> > 
> > ERROR: code indent should never use tabs
> > #781: FILE: tcmu/helper.c:272:
> > +^I^I^Ival16 = htobe16(0x0001);$
> > 
> > ERROR: code indent should never use tabs
> > #782: FILE: tcmu/helper.c:273:
> > +^I^I^Imemcpy(&data[4], &val16, 2);$
> > 
> > ERROR: code indent should never use tabs
> > #783: FILE: tcmu/helper.c:274:
> > +^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #785: FILE: tcmu/helper.c:276:
> > +^I^Itcmu_memcpy_into_iovec(iovec, iov_cnt, data, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #786: FILE: tcmu/helper.c:277:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #787: FILE: tcmu/helper.c:278:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #788: FILE: tcmu/helper.c:279:
> > +^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #789: FILE: tcmu/helper.c:280:
> > +^Icase 0xb2: /* Logical Block Provisioning VPD page */$
> > 
> > ERROR: code indent should never use tabs
> > #790: FILE: tcmu/helper.c:281:
> > +^I{$
> > 
> > ERROR: code indent should never use tabs
> > #791: FILE: tcmu/helper.c:282:
> > +^I^Ichar data[64];$
> > 
> > ERROR: code indent should never use tabs
> > #792: FILE: tcmu/helper.c:283:
> > +^I^Iuint16_t val16;$
> > 
> > ERROR: code indent should never use tabs
> > #794: FILE: tcmu/helper.c:285:
> > +^I^Imemset(data, 0, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #796: FILE: tcmu/helper.c:287:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #797: FILE: tcmu/helper.c:288:
> > +^I^I * From spc-5 Revision 14, section 6.7.2 Standard INQUIRY data$
> > 
> > ERROR: code indent should never use tabs
> > #798: FILE: tcmu/helper.c:289:
> > +^I^I * set the device type to Direct access block device.$
> > 
> > ERROR: code indent should never use tabs
> > #799: FILE: tcmu/helper.c:290:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #800: FILE: tcmu/helper.c:291:
> > +^I^Idata[0] = 0x00;$
> > 
> > ERROR: code indent should never use tabs
> > #802: FILE: tcmu/helper.c:293:
> > +^I^I/* PAGE CODE (B2h) */$
> > 
> > ERROR: code indent should never use tabs
> > #803: FILE: tcmu/helper.c:294:
> > +^I^Idata[1] = 0xb2;$
> > 
> > ERROR: code indent should never use tabs
> > #805: FILE: tcmu/helper.c:296:
> > +^I^I/*$
> > 
> > WARNING: line over 80 characters
> > #806: FILE: tcmu/helper.c:297:
> > +                * PAGE LENGTH field: PROVISIONING GROUP DESCRIPTOR field will be
> > 
> > ERROR: code indent should never use tabs
> > #806: FILE: tcmu/helper.c:297:
> > +^I^I * PAGE LENGTH field: PROVISIONING GROUP DESCRIPTOR field will be$
> > 
> > ERROR: code indent should never use tabs
> > #807: FILE: tcmu/helper.c:298:
> > +^I^I * not present.$
> > 
> > ERROR: code indent should never use tabs
> > #808: FILE: tcmu/helper.c:299:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #809: FILE: tcmu/helper.c:300:
> > +^I^Ival16 = htobe16(0x0004);$
> > 
> > ERROR: code indent should never use tabs
> > #810: FILE: tcmu/helper.c:301:
> > +^I^Imemcpy(&data[2], &val16, 2);$
> > 
> > ERROR: code indent should never use tabs
> > #812: FILE: tcmu/helper.c:303:
> > +^I^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #813: FILE: tcmu/helper.c:304:
> > +^I^I * The logical block provisioning read zeros (LBPRZ) field.$
> > 
> > ERROR: code indent should never use tabs
> > #814: FILE: tcmu/helper.c:305:
> > +^I^I *$
> > 
> > WARNING: line over 80 characters
> > #815: FILE: tcmu/helper.c:306:
> > +                * The logical block data represented by unmapped LBAs is set to zeros
> > 
> > ERROR: code indent should never use tabs
> > #815: FILE: tcmu/helper.c:306:
> > +^I^I * The logical block data represented by unmapped LBAs is set to zeros$
> > 
> > ERROR: code indent should never use tabs
> > #816: FILE: tcmu/helper.c:307:
> > +^I^I */$
> > 
> > ERROR: code indent should never use tabs
> > #817: FILE: tcmu/helper.c:308:
> > +^I^Idata[5] = 0x04;$
> > 
> > ERROR: code indent should never use tabs
> > #819: FILE: tcmu/helper.c:310:
> > +^I^Itcmu_memcpy_into_iovec(iovec, iov_cnt, data, sizeof(data));$
> > 
> > ERROR: code indent should never use tabs
> > #820: FILE: tcmu/helper.c:311:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #821: FILE: tcmu/helper.c:312:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #822: FILE: tcmu/helper.c:313:
> > +^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #823: FILE: tcmu/helper.c:314:
> > +^Idefault:$
> > 
> > ERROR: code indent should never use tabs
> > #824: FILE: tcmu/helper.c:315:
> > +^I^Ierror_report("Vital product data page code 0x%x not support\n",$
> > 
> > ERROR: Error messages should not contain newlines
> > #824: FILE: tcmu/helper.c:315:
> > +               error_report("Vital product data page code 0x%x not support\n",
> > 
> > ERROR: code indent should never use tabs
> > #825: FILE: tcmu/helper.c:316:
> > +^I^I^I     cdb[2]);$
> > 
> > ERROR: code indent should never use tabs
> > #826: FILE: tcmu/helper.c:317:
> > +^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #827: FILE: tcmu/helper.c:318:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #834: FILE: tcmu/helper.c:325:
> > +^Istruct tcmu_device *dev,$
> > 
> > ERROR: code indent should never use tabs
> > #835: FILE: tcmu/helper.c:326:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #836: FILE: tcmu/helper.c:327:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #837: FILE: tcmu/helper.c:328:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #839: FILE: tcmu/helper.c:330:
> > +^Iif (!(cdb[1] & 0x01)) {$
> > 
> > ERROR: code indent should never use tabs
> > #840: FILE: tcmu/helper.c:331:
> > +^I^Iif (!cdb[2])$
> > 
> > ERROR: code indent should never use tabs
> > #841: FILE: tcmu/helper.c:332:
> > +^I^I^Ireturn tcmu_emulate_std_inquiry(cdb, iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #842: FILE: tcmu/helper.c:333:
> > +^I^I^I^I^I^I^Iiov_cnt);$
> > 
> > ERROR: code indent should never use tabs
> > #843: FILE: tcmu/helper.c:334:
> > +^I^Ielse$
> > 
> > ERROR: code indent should never use tabs
> > #844: FILE: tcmu/helper.c:335:
> > +^I^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #845: FILE: tcmu/helper.c:336:
> > +^I} else {$
> > 
> > ERROR: code indent should never use tabs
> > #846: FILE: tcmu/helper.c:337:
> > +^I^Ireturn tcmu_emulate_evpd_inquiry(dev, cdb, iovec, iov_cnt);$
> > 
> > ERROR: code indent should never use tabs
> > #847: FILE: tcmu/helper.c:338:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #851: FILE: tcmu/helper.c:342:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #852: FILE: tcmu/helper.c:343:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #853: FILE: tcmu/helper.c:344:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #855: FILE: tcmu/helper.c:346:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #859: FILE: tcmu/helper.c:350:
> > +^Iuint64_t num_lbas,$
> > 
> > ERROR: code indent should never use tabs
> > #860: FILE: tcmu/helper.c:351:
> > +^Iuint32_t block_size,$
> > 
> > ERROR: code indent should never use tabs
> > #861: FILE: tcmu/helper.c:352:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #862: FILE: tcmu/helper.c:353:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #863: FILE: tcmu/helper.c:354:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #865: FILE: tcmu/helper.c:356:
> > +^Iuint8_t buf[8];$
> > 
> > ERROR: code indent should never use tabs
> > #866: FILE: tcmu/helper.c:357:
> > +^Iuint32_t val32;$
> > 
> > ERROR: code indent should never use tabs
> > #868: FILE: tcmu/helper.c:359:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #870: FILE: tcmu/helper.c:361:
> > +^Iif (num_lbas < 0x100000000ULL) {$
> > 
> > ERROR: code indent should never use tabs
> > #871: FILE: tcmu/helper.c:362:
> > +^I^I// Return the LBA of the last logical block, so subtract 1.$
> > 
> > ERROR: do not use C99 // comments
> > #871: FILE: tcmu/helper.c:362:
> > +               // Return the LBA of the last logical block, so subtract 1.
> > 
> > ERROR: code indent should never use tabs
> > #872: FILE: tcmu/helper.c:363:
> > +^I^Ival32 = htobe32(num_lbas-1);$
> > 
> > ERROR: spaces required around that '-' (ctx:VxV)
> > #872: FILE: tcmu/helper.c:363:
> > +               val32 = htobe32(num_lbas-1);
> >                                         ^
> > 
> > ERROR: code indent should never use tabs
> > #873: FILE: tcmu/helper.c:364:
> > +^I} else {$
> > 
> > ERROR: code indent should never use tabs
> > #874: FILE: tcmu/helper.c:365:
> > +^I^I// This lets the initiator know that he needs to use$
> > 
> > ERROR: do not use C99 // comments
> > #874: FILE: tcmu/helper.c:365:
> > +               // This lets the initiator know that he needs to use
> > 
> > ERROR: code indent should never use tabs
> > #875: FILE: tcmu/helper.c:366:
> > +^I^I// Read Capacity(16).$
> > 
> > ERROR: do not use C99 // comments
> > #875: FILE: tcmu/helper.c:366:
> > +               // Read Capacity(16).
> > 
> > ERROR: code indent should never use tabs
> > #876: FILE: tcmu/helper.c:367:
> > +^I^Ival32 = 0xffffffff;$
> > 
> > ERROR: code indent should never use tabs
> > #877: FILE: tcmu/helper.c:368:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #879: FILE: tcmu/helper.c:370:
> > +^Imemcpy(&buf[0], &val32, 4);$
> > 
> > ERROR: code indent should never use tabs
> > #881: FILE: tcmu/helper.c:372:
> > +^Ival32 = htobe32(block_size);$
> > 
> > ERROR: code indent should never use tabs
> > #882: FILE: tcmu/helper.c:373:
> > +^Imemcpy(&buf[4], &val32, 4);$
> > 
> > ERROR: code indent should never use tabs
> > #884: FILE: tcmu/helper.c:375:
> > +^I/* all else is zero */$
> > 
> > ERROR: code indent should never use tabs
> > #886: FILE: tcmu/helper.c:377:
> > +^Itcmu_memcpy_into_iovec(iovec, iov_cnt, buf, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #888: FILE: tcmu/helper.c:379:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #892: FILE: tcmu/helper.c:383:
> > +^Iuint64_t num_lbas,$
> > 
> > ERROR: code indent should never use tabs
> > #893: FILE: tcmu/helper.c:384:
> > +^Iuint32_t block_size,$
> > 
> > ERROR: code indent should never use tabs
> > #894: FILE: tcmu/helper.c:385:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #895: FILE: tcmu/helper.c:386:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #896: FILE: tcmu/helper.c:387:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #898: FILE: tcmu/helper.c:389:
> > +^Iuint8_t buf[32];$
> > 
> > ERROR: code indent should never use tabs
> > #899: FILE: tcmu/helper.c:390:
> > +^Iuint64_t val64;$
> > 
> > ERROR: code indent should never use tabs
> > #900: FILE: tcmu/helper.c:391:
> > +^Iuint32_t val32;$
> > 
> > ERROR: code indent should never use tabs
> > #902: FILE: tcmu/helper.c:393:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #904: FILE: tcmu/helper.c:395:
> > +^I// Return the LBA of the last logical block, so subtract 1.$
> > 
> > ERROR: do not use C99 // comments
> > #904: FILE: tcmu/helper.c:395:
> > +       // Return the LBA of the last logical block, so subtract 1.
> > 
> > ERROR: code indent should never use tabs
> > #905: FILE: tcmu/helper.c:396:
> > +^Ival64 = htobe64(num_lbas-1);$
> > 
> > ERROR: spaces required around that '-' (ctx:VxV)
> > #905: FILE: tcmu/helper.c:396:
> > +       val64 = htobe64(num_lbas-1);
> >                                 ^
> > 
> > ERROR: code indent should never use tabs
> > #906: FILE: tcmu/helper.c:397:
> > +^Imemcpy(&buf[0], &val64, 8);$
> > 
> > ERROR: code indent should never use tabs
> > #908: FILE: tcmu/helper.c:399:
> > +^Ival32 = htobe32(block_size);$
> > 
> > ERROR: code indent should never use tabs
> > #909: FILE: tcmu/helper.c:400:
> > +^Imemcpy(&buf[8], &val32, 4);$
> > 
> > ERROR: code indent should never use tabs
> > #911: FILE: tcmu/helper.c:402:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #912: FILE: tcmu/helper.c:403:
> > +^I * Logical Block Provisioning Management Enabled (LBPME) bit$
> > 
> > ERROR: code indent should never use tabs
> > #913: FILE: tcmu/helper.c:404:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #914: FILE: tcmu/helper.c:405:
> > +^I * The LBPME bit sets to one and then the logical unit implements$
> > 
> > ERROR: code indent should never use tabs
> > #915: FILE: tcmu/helper.c:406:
> > +^I * logical block provisioning management$
> > 
> > ERROR: code indent should never use tabs
> > #916: FILE: tcmu/helper.c:407:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #917: FILE: tcmu/helper.c:408:
> > +^Ibuf[14] = 0x80;$
> > 
> > ERROR: code indent should never use tabs
> > #919: FILE: tcmu/helper.c:410:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #920: FILE: tcmu/helper.c:411:
> > +^I * The logical block provisioning read zeros (LBPRZ) bit shall be$
> > 
> > ERROR: code indent should never use tabs
> > #921: FILE: tcmu/helper.c:412:
> > +^I * set to one if the LBPRZ field is set to xx1b in VPD B2. The$
> > 
> > ERROR: code indent should never use tabs
> > #922: FILE: tcmu/helper.c:413:
> > +^I * LBPRZ bit shall be set to zero if the LBPRZ field is not set$
> > 
> > ERROR: code indent should never use tabs
> > #923: FILE: tcmu/helper.c:414:
> > +^I * to xx1b.$
> > 
> > ERROR: code indent should never use tabs
> > #924: FILE: tcmu/helper.c:415:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #925: FILE: tcmu/helper.c:416:
> > +^Ibuf[14] |= 0x40;$
> > 
> > ERROR: code indent should never use tabs
> > #927: FILE: tcmu/helper.c:418:
> > +^I/* all else is zero */$
> > 
> > ERROR: code indent should never use tabs
> > #929: FILE: tcmu/helper.c:420:
> > +^Itcmu_memcpy_into_iovec(iovec, iov_cnt, buf, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #931: FILE: tcmu/helper.c:422:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #935: FILE: tcmu/helper.c:426:
> > +^I^I^I^I uint8_t *from_buf, size_t from_len)$
> > 
> > ERROR: code indent should never use tabs
> > #937: FILE: tcmu/helper.c:428:
> > +^Iif (!to_buf)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #937: FILE: tcmu/helper.c:428:
> > +       if (!to_buf)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #938: FILE: tcmu/helper.c:429:
> > +^I^Ireturn;$
> > 
> > ERROR: code indent should never use tabs
> > #939: FILE: tcmu/helper.c:430:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #940: FILE: tcmu/helper.c:431:
> > +^I * SPC 4r37: 4.3.5.6 Allocation length:$
> > 
> > ERROR: code indent should never use tabs
> > #941: FILE: tcmu/helper.c:432:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #942: FILE: tcmu/helper.c:433:
> > +^I * The device server shall terminate transfers to the Data-In Buffer$
> > 
> > ERROR: code indent should never use tabs
> > #943: FILE: tcmu/helper.c:434:
> > +^I * when the number of bytes or blocks specified by the ALLOCATION$
> > 
> > ERROR: code indent should never use tabs
> > #944: FILE: tcmu/helper.c:435:
> > +^I * LENGTH field have been transferred or when all available data$
> > 
> > ERROR: code indent should never use tabs
> > #945: FILE: tcmu/helper.c:436:
> > +^I * have been transferred, whichever is less.$
> > 
> > ERROR: code indent should never use tabs
> > #946: FILE: tcmu/helper.c:437:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #947: FILE: tcmu/helper.c:438:
> > +^Imemcpy(to_buf, from_buf, to_len > from_len ? from_len : to_len);$
> > 
> > ERROR: code indent should never use tabs
> > #951: FILE: tcmu/helper.c:442:
> > +^I^I^I   size_t ret_buf_len)$
> > 
> > ERROR: code indent should never use tabs
> > #953: FILE: tcmu/helper.c:444:
> > +^Iuint8_t buf[12];$
> > 
> > ERROR: code indent should never use tabs
> > #955: FILE: tcmu/helper.c:446:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #956: FILE: tcmu/helper.c:447:
> > +^Ibuf[0] = 0x1;$
> > 
> > ERROR: code indent should never use tabs
> > #957: FILE: tcmu/helper.c:448:
> > +^Ibuf[1] = 0xa;$
> > 
> > ERROR: code indent should never use tabs
> > #959: FILE: tcmu/helper.c:450:
> > +^Icopy_to_response_buf(ret_buf, ret_buf_len, buf, 12);$
> > 
> > ERROR: code indent should never use tabs
> > #960: FILE: tcmu/helper.c:451:
> > +^Ireturn 12;$
> > 
> > ERROR: code indent should never use tabs
> > #964: FILE: tcmu/helper.c:455:
> > +^I^I      size_t ret_buf_len)$
> > 
> > ERROR: code indent should never use tabs
> > #966: FILE: tcmu/helper.c:457:
> > +^Iuint8_t buf[20];$
> > 
> > ERROR: code indent should never use tabs
> > #968: FILE: tcmu/helper.c:459:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #969: FILE: tcmu/helper.c:460:
> > +^Ibuf[0] = 0x8;$
> > 
> > ERROR: code indent should never use tabs
> > #970: FILE: tcmu/helper.c:461:
> > +^Ibuf[1] = 0x12;$
> > 
> > ERROR: code indent should never use tabs
> > #972: FILE: tcmu/helper.c:463:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #973: FILE: tcmu/helper.c:464:
> > +^I * If device supports a writeback cache then set writeback$
> > 
> > ERROR: code indent should never use tabs
> > #974: FILE: tcmu/helper.c:465:
> > +^I * cache enable (WCE)$
> > 
> > ERROR: code indent should never use tabs
> > #975: FILE: tcmu/helper.c:466:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #976: FILE: tcmu/helper.c:467:
> > +^Iif (tcmu_dev_get_write_cache_enabled(dev))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #976: FILE: tcmu/helper.c:467:
> > +       if (tcmu_dev_get_write_cache_enabled(dev))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #977: FILE: tcmu/helper.c:468:
> > +^I^Ibuf[2] = 0x4;$
> > 
> > ERROR: code indent should never use tabs
> > #979: FILE: tcmu/helper.c:470:
> > +^Icopy_to_response_buf(ret_buf, ret_buf_len, buf, 20);$
> > 
> > ERROR: code indent should never use tabs
> > #980: FILE: tcmu/helper.c:471:
> > +^Ireturn 20;$
> > 
> > ERROR: code indent should never use tabs
> > #984: FILE: tcmu/helper.c:475:
> > +^I^I^I       size_t ret_buf_len)$
> > 
> > ERROR: code indent should never use tabs
> > #986: FILE: tcmu/helper.c:477:
> > +^Iuint8_t buf[12];$
> > 
> > ERROR: code indent should never use tabs
> > #988: FILE: tcmu/helper.c:479:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #989: FILE: tcmu/helper.c:480:
> > +^Ibuf[0] = 0x0a;$
> > 
> > ERROR: code indent should never use tabs
> > #990: FILE: tcmu/helper.c:481:
> > +^Ibuf[1] = 0x0a;$
> > 
> > ERROR: code indent should never use tabs
> > #992: FILE: tcmu/helper.c:483:
> > +^I/* From spc4r31, section 7.5.7 Control mode Page$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #992: FILE: tcmu/helper.c:483:
> > +       /* From spc4r31, section 7.5.7 Control mode Page
> > 
> > ERROR: code indent should never use tabs
> > #993: FILE: tcmu/helper.c:484:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #994: FILE: tcmu/helper.c:485:
> > +^I * GLTSD = 1: because we don't implicitly save log parameters$
> > 
> > ERROR: code indent should never use tabs
> > #995: FILE: tcmu/helper.c:486:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #996: FILE: tcmu/helper.c:487:
> > +^I * A global logging target save disable (GLTSD) bit set to$
> > 
> > ERROR: code indent should never use tabs
> > #997: FILE: tcmu/helper.c:488:
> > +^I * zero specifies that the logical unit implicitly saves, at$
> > 
> > ERROR: code indent should never use tabs
> > #998: FILE: tcmu/helper.c:489:
> > +^I * vendor specific intervals, each log parameter in which the$
> > 
> > ERROR: code indent should never use tabs
> > #999: FILE: tcmu/helper.c:490:
> > +^I * TSD bit (see 7.3) is set to zero. A GLTSD bit set to one$
> > 
> > ERROR: code indent should never use tabs
> > #1000: FILE: tcmu/helper.c:491:
> > +^I * specifies that the logical unit shall not implicitly save$
> > 
> > ERROR: code indent should never use tabs
> > #1001: FILE: tcmu/helper.c:492:
> > +^I * any log parameters.$
> > 
> > ERROR: code indent should never use tabs
> > #1002: FILE: tcmu/helper.c:493:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #1003: FILE: tcmu/helper.c:494:
> > +^Ibuf[2] = 0x02;$
> > 
> > ERROR: code indent should never use tabs
> > #1005: FILE: tcmu/helper.c:496:
> > +^I/* From spc4r31, section 7.5.7 Control mode Page$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1005: FILE: tcmu/helper.c:496:
> > +       /* From spc4r31, section 7.5.7 Control mode Page
> > 
> > ERROR: code indent should never use tabs
> > #1006: FILE: tcmu/helper.c:497:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #1007: FILE: tcmu/helper.c:498:
> > +^I * TAS = 1: Currently not settable by tcmu. Using the LIO default$
> > 
> > ERROR: code indent should never use tabs
> > #1008: FILE: tcmu/helper.c:499:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #1009: FILE: tcmu/helper.c:500:
> > +^I * A task aborted status (TAS) bit set to zero specifies that$
> > 
> > ERROR: code indent should never use tabs
> > #1010: FILE: tcmu/helper.c:501:
> > +^I * aborted commands shall be terminated by the device server$
> > 
> > ERROR: code indent should never use tabs
> > #1011: FILE: tcmu/helper.c:502:
> > +^I * without any response to the application client. A TAS bit$
> > 
> > ERROR: code indent should never use tabs
> > #1012: FILE: tcmu/helper.c:503:
> > +^I * set to one specifies that commands aborted by the actions$
> > 
> > ERROR: code indent should never use tabs
> > #1013: FILE: tcmu/helper.c:504:
> > +^I * of an I_T nexus other than the I_T nexus on which the command$
> > 
> > ERROR: code indent should never use tabs
> > #1014: FILE: tcmu/helper.c:505:
> > +^I * was received shall be completed with TASK ABORTED status$
> > 
> > ERROR: code indent should never use tabs
> > #1015: FILE: tcmu/helper.c:506:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #1016: FILE: tcmu/helper.c:507:
> > +^Ibuf[5] = 0x40;$
> > 
> > ERROR: code indent should never use tabs
> > #1018: FILE: tcmu/helper.c:509:
> > +^I/* From spc4r31, section 7.5.7 Control mode Page$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1018: FILE: tcmu/helper.c:509:
> > +       /* From spc4r31, section 7.5.7 Control mode Page
> > 
> > ERROR: code indent should never use tabs
> > #1019: FILE: tcmu/helper.c:510:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #1020: FILE: tcmu/helper.c:511:
> > +^I * BUSY TIMEOUT PERIOD: Currently is unlimited$
> > 
> > ERROR: code indent should never use tabs
> > #1021: FILE: tcmu/helper.c:512:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #1022: FILE: tcmu/helper.c:513:
> > +^I * The BUSY TIMEOUT PERIOD field specifies the maximum time, in$
> > 
> > ERROR: code indent should never use tabs
> > #1023: FILE: tcmu/helper.c:514:
> > +^I * 100 milliseconds increments, that the application client allows$
> > 
> > ERROR: code indent should never use tabs
> > #1024: FILE: tcmu/helper.c:515:
> > +^I * for the device server to return BUSY status for unanticipated$
> > 
> > ERROR: code indent should never use tabs
> > #1025: FILE: tcmu/helper.c:516:
> > +^I * conditions that are not a routine part of commands from the$
> > 
> > ERROR: code indent should never use tabs
> > #1026: FILE: tcmu/helper.c:517:
> > +^I * application client. This value may be rounded down as defined$
> > 
> > ERROR: code indent should never use tabs
> > #1027: FILE: tcmu/helper.c:518:
> > +^I * in 5.4(the Parameter rounding section).$
> > 
> > ERROR: code indent should never use tabs
> > #1028: FILE: tcmu/helper.c:519:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #1029: FILE: tcmu/helper.c:520:
> > +^I * A 0000h value in this field is undefined by this standard.$
> > 
> > ERROR: code indent should never use tabs
> > #1030: FILE: tcmu/helper.c:521:
> > +^I * An FFFFh value in this field is defined as an unlimited period.$
> > 
> > ERROR: code indent should never use tabs
> > #1031: FILE: tcmu/helper.c:522:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #1032: FILE: tcmu/helper.c:523:
> > +^Ibuf[8] = 0xff;$
> > 
> > ERROR: code indent should never use tabs
> > #1033: FILE: tcmu/helper.c:524:
> > +^Ibuf[9] = 0xff;$
> > 
> > ERROR: code indent should never use tabs
> > #1035: FILE: tcmu/helper.c:526:
> > +^Icopy_to_response_buf(ret_buf, ret_buf_len, buf, 12);$
> > 
> > ERROR: code indent should never use tabs
> > #1036: FILE: tcmu/helper.c:527:
> > +^Ireturn 12;$
> > 
> > ERROR: code indent should never use tabs
> > #1041: FILE: tcmu/helper.c:532:
> > +^Iuint8_t page;$
> > 
> > ERROR: code indent should never use tabs
> > #1042: FILE: tcmu/helper.c:533:
> > +^Iuint8_t subpage;$
> > 
> > ERROR: code indent should never use tabs
> > #1043: FILE: tcmu/helper.c:534:
> > +^Iint (*get)(struct tcmu_device *dev, uint8_t *buf, size_t buf_len);$
> > 
> > ERROR: code indent should never use tabs
> > #1045: FILE: tcmu/helper.c:536:
> > +^I{0x1, 0, handle_rwrecovery_page},$
> > 
> > ERROR: code indent should never use tabs
> > #1046: FILE: tcmu/helper.c:537:
> > +^I{0x8, 0, handle_cache_page},$
> > 
> > ERROR: code indent should never use tabs
> > #1047: FILE: tcmu/helper.c:538:
> > +^I{0xa, 0, handle_control_page},$
> > 
> > ERROR: code indent should never use tabs
> > #1051: FILE: tcmu/helper.c:542:
> > +^I^I^I^I struct mode_sense_handler *handler,$
> > 
> > ERROR: code indent should never use tabs
> > #1052: FILE: tcmu/helper.c:543:
> > +^I^I^I^I uint8_t **buf, size_t alloc_len,$
> > 
> > ERROR: code indent should never use tabs
> > #1053: FILE: tcmu/helper.c:544:
> > +^I^I^I^I size_t *used_len, bool sense_ten)$
> > 
> > ERROR: code indent should never use tabs
> > #1055: FILE: tcmu/helper.c:546:
> > +^Iint ret;$
> > 
> > ERROR: code indent should never use tabs
> > #1057: FILE: tcmu/helper.c:548:
> > +^Iret = handler->get(dev, *buf, alloc_len - *used_len);$
> > 
> > ERROR: code indent should never use tabs
> > #1059: FILE: tcmu/helper.c:550:
> > +^Iif  (!sense_ten && (*used_len + ret >= 255))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1059: FILE: tcmu/helper.c:550:
> > +       if  (!sense_ten && (*used_len + ret >= 255))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1060: FILE: tcmu/helper.c:551:
> > +^I^Ireturn -EINVAL;$
> > 
> > ERROR: code indent should never use tabs
> > #1062: FILE: tcmu/helper.c:553:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #1063: FILE: tcmu/helper.c:554:
> > +^I * SPC 4r37: 4.3.5.6 Allocation length:$
> > 
> > ERROR: code indent should never use tabs
> > #1064: FILE: tcmu/helper.c:555:
> > +^I *$
> > 
> > ERROR: code indent should never use tabs
> > #1065: FILE: tcmu/helper.c:556:
> > +^I * If the information being transferred to the Data-In Buffer includes$
> > 
> > ERROR: code indent should never use tabs
> > #1066: FILE: tcmu/helper.c:557:
> > +^I * fields containing counts of the number of bytes in some or all of$
> > 
> > ERROR: code indent should never use tabs
> > #1067: FILE: tcmu/helper.c:558:
> > +^I * the data (e.g., the PARAMETER DATA LENGTH field, the PAGE LENGTH$
> > 
> > ERROR: code indent should never use tabs
> > #1068: FILE: tcmu/helper.c:559:
> > +^I * field, the DESCRIPTOR LENGTH field, the AVAILABLE DATA field),$
> > 
> > ERROR: code indent should never use tabs
> > #1069: FILE: tcmu/helper.c:560:
> > +^I * then the contents of these fields shall not be altered to reflect$
> > 
> > ERROR: code indent should never use tabs
> > #1070: FILE: tcmu/helper.c:561:
> > +^I * the truncation, if any, that results from an insufficient$
> > 
> > ERROR: code indent should never use tabs
> > #1071: FILE: tcmu/helper.c:562:
> > +^I * ALLOCATION LENGTH value$
> > 
> > ERROR: code indent should never use tabs
> > #1072: FILE: tcmu/helper.c:563:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #1073: FILE: tcmu/helper.c:564:
> > +^I/*$
> > 
> > ERROR: code indent should never use tabs
> > #1074: FILE: tcmu/helper.c:565:
> > +^I * Setup the buffer so to still loop over the handlers, but just$
> > 
> > ERROR: code indent should never use tabs
> > #1075: FILE: tcmu/helper.c:566:
> > +^I * increment the used_len so we can return the$
> > 
> > ERROR: code indent should never use tabs
> > #1076: FILE: tcmu/helper.c:567:
> > +^I * final value.$
> > 
> > ERROR: code indent should never use tabs
> > #1077: FILE: tcmu/helper.c:568:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #1078: FILE: tcmu/helper.c:569:
> > +^Iif (*buf && (*used_len + ret >= alloc_len))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1078: FILE: tcmu/helper.c:569:
> > +       if (*buf && (*used_len + ret >= alloc_len))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1079: FILE: tcmu/helper.c:570:
> > +^I^I*buf = NULL;$
> > 
> > ERROR: code indent should never use tabs
> > #1081: FILE: tcmu/helper.c:572:
> > +^I*used_len += ret;$
> > 
> > ERROR: code indent should never use tabs
> > #1082: FILE: tcmu/helper.c:573:
> > +^Iif (*buf)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1082: FILE: tcmu/helper.c:573:
> > +       if (*buf)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1083: FILE: tcmu/helper.c:574:
> > +^I^I*buf += ret;$
> > 
> > ERROR: code indent should never use tabs
> > #1084: FILE: tcmu/helper.c:575:
> > +^Ireturn ret;$
> > 
> > ERROR: code indent should never use tabs
> > #1093: FILE: tcmu/helper.c:584:
> > +^Istruct tcmu_device *dev,$
> > 
> > ERROR: code indent should never use tabs
> > #1094: FILE: tcmu/helper.c:585:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #1095: FILE: tcmu/helper.c:586:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #1096: FILE: tcmu/helper.c:587:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #1098: FILE: tcmu/helper.c:589:
> > +^Ibool sense_ten = (cdb[0] == MODE_SENSE_10);$
> > 
> > ERROR: code indent should never use tabs
> > #1099: FILE: tcmu/helper.c:590:
> > +^Iuint8_t page_code = cdb[2] & 0x3f;$
> > 
> > ERROR: code indent should never use tabs
> > #1100: FILE: tcmu/helper.c:591:
> > +^Iuint8_t subpage_code = cdb[3];$
> > 
> > ERROR: code indent should never use tabs
> > #1101: FILE: tcmu/helper.c:592:
> > +^Isize_t alloc_len = tcmu_dev_get_max_xfer_len(dev);$
> > 
> > ERROR: code indent should never use tabs
> > #1102: FILE: tcmu/helper.c:593:
> > +^Iint i;$
> > 
> > ERROR: code indent should never use tabs
> > #1103: FILE: tcmu/helper.c:594:
> > +^Iint ret;$
> > 
> > ERROR: code indent should never use tabs
> > #1104: FILE: tcmu/helper.c:595:
> > +^Isize_t used_len;$
> > 
> > ERROR: code indent should never use tabs
> > #1105: FILE: tcmu/helper.c:596:
> > +^Iuint8_t *buf;$
> > 
> > ERROR: code indent should never use tabs
> > #1106: FILE: tcmu/helper.c:597:
> > +^Iuint8_t *orig_buf = NULL;$
> > 
> > ERROR: code indent should never use tabs
> > #1108: FILE: tcmu/helper.c:599:
> > +^Iif (!alloc_len)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1108: FILE: tcmu/helper.c:599:
> > +       if (!alloc_len)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1109: FILE: tcmu/helper.c:600:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #1111: FILE: tcmu/helper.c:602:
> > +^I/* Mode parameter header. Mode data length filled in at the end. */$
> > 
> > ERROR: code indent should never use tabs
> > #1112: FILE: tcmu/helper.c:603:
> > +^Iused_len = sense_ten ? 8 : 4;$
> > 
> > ERROR: code indent should never use tabs
> > #1113: FILE: tcmu/helper.c:604:
> > +^Iif (used_len > alloc_len)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1113: FILE: tcmu/helper.c:604:
> > +       if (used_len > alloc_len)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1114: FILE: tcmu/helper.c:605:
> > +^I^Igoto fail;$
> > 
> > ERROR: code indent should never use tabs
> > #1116: FILE: tcmu/helper.c:607:
> > +^Ibuf = calloc(1, alloc_len);$
> > 
> > ERROR: code indent should never use tabs
> > #1117: FILE: tcmu/helper.c:608:
> > +^Iif (!buf)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1117: FILE: tcmu/helper.c:608:
> > +       if (!buf)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1118: FILE: tcmu/helper.c:609:
> > +^I^Ireturn TCMU_STS_NO_RESOURCE;$
> > 
> > ERROR: code indent should never use tabs
> > #1120: FILE: tcmu/helper.c:611:
> > +^Iorig_buf = buf;$
> > 
> > ERROR: code indent should never use tabs
> > #1121: FILE: tcmu/helper.c:612:
> > +^Ibuf += used_len;$
> > 
> > ERROR: code indent should never use tabs
> > #1123: FILE: tcmu/helper.c:614:
> > +^I/* Don't fill in device-specific parameter */$
> > 
> > ERROR: code indent should never use tabs
> > #1124: FILE: tcmu/helper.c:615:
> > +^I/* This helper fn doesn't support sw write protect (SWP) */$
> > 
> > ERROR: code indent should never use tabs
> > #1126: FILE: tcmu/helper.c:617:
> > +^I/* Don't report block descriptors */$
> > 
> > ERROR: code indent should never use tabs
> > #1128: FILE: tcmu/helper.c:619:
> > +^Iif (page_code == 0x3f) {$
> > 
> > ERROR: code indent should never use tabs
> > #1129: FILE: tcmu/helper.c:620:
> > +^I^Ifor (i = 0; i < ARRAY_SIZE(modesense_handlers); i++) {$
> > 
> > ERROR: code indent should never use tabs
> > #1130: FILE: tcmu/helper.c:621:
> > +^I^I^Iret = handle_mode_sense(dev, &modesense_handlers[i],$
> > 
> > ERROR: code indent should never use tabs
> > #1131: FILE: tcmu/helper.c:622:
> > +^I^I^I^I^I^I&buf, alloc_len, &used_len,$
> > 
> > ERROR: code indent should never use tabs
> > #1132: FILE: tcmu/helper.c:623:
> > +^I^I^I^I^I^Isense_ten);$
> > 
> > ERROR: code indent should never use tabs
> > #1133: FILE: tcmu/helper.c:624:
> > +^I^I^Iif (ret < 0)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1133: FILE: tcmu/helper.c:624:
> > +                       if (ret < 0)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1134: FILE: tcmu/helper.c:625:
> > +^I^I^I^Igoto free_buf;$
> > 
> > ERROR: code indent should never use tabs
> > #1135: FILE: tcmu/helper.c:626:
> > +^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1136: FILE: tcmu/helper.c:627:
> > +^I} else {$
> > 
> > ERROR: code indent should never use tabs
> > #1137: FILE: tcmu/helper.c:628:
> > +^I^Iret = 0;$
> > 
> > ERROR: code indent should never use tabs
> > #1139: FILE: tcmu/helper.c:630:
> > +^I^Ifor (i = 0; i < ARRAY_SIZE(modesense_handlers); i++) {$
> > 
> > ERROR: code indent should never use tabs
> > #1140: FILE: tcmu/helper.c:631:
> > +^I^I^Iif (page_code == modesense_handlers[i].page &&$
> > 
> > ERROR: code indent should never use tabs
> > #1141: FILE: tcmu/helper.c:632:
> > +^I^I^I    subpage_code == modesense_handlers[i].subpage) {$
> > 
> > ERROR: code indent should never use tabs
> > #1142: FILE: tcmu/helper.c:633:
> > +^I^I^I^Iret = handle_mode_sense(dev,$
> > 
> > ERROR: code indent should never use tabs
> > #1143: FILE: tcmu/helper.c:634:
> > +^I^I^I^I^I^I^I&modesense_handlers[i],$
> > 
> > ERROR: code indent should never use tabs
> > #1144: FILE: tcmu/helper.c:635:
> > +^I^I^I^I^I^I^I&buf, alloc_len,$
> > 
> > ERROR: code indent should never use tabs
> > #1145: FILE: tcmu/helper.c:636:
> > +^I^I^I^I^I^I^I&used_len, sense_ten);$
> > 
> > ERROR: code indent should never use tabs
> > #1146: FILE: tcmu/helper.c:637:
> > +^I^I^I^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #1147: FILE: tcmu/helper.c:638:
> > +^I^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1148: FILE: tcmu/helper.c:639:
> > +^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1150: FILE: tcmu/helper.c:641:
> > +^I^Iif (ret <= 0)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1150: FILE: tcmu/helper.c:641:
> > +               if (ret <= 0)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1151: FILE: tcmu/helper.c:642:
> > +^I^I^Igoto free_buf;$
> > 
> > ERROR: code indent should never use tabs
> > #1152: FILE: tcmu/helper.c:643:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1154: FILE: tcmu/helper.c:645:
> > +^Iif (sense_ten) {$
> > 
> > ERROR: code indent should never use tabs
> > #1155: FILE: tcmu/helper.c:646:
> > +^I^Iuint16_t *ptr = (uint16_t*) orig_buf;$
> > 
> > ERROR: "(foo*)" should be "(foo *)"
> > #1155: FILE: tcmu/helper.c:646:
> > +               uint16_t *ptr = (uint16_t*) orig_buf;
> > 
> > ERROR: code indent should never use tabs
> > #1156: FILE: tcmu/helper.c:647:
> > +^I^I*ptr = htobe16(used_len - 2);$
> > 
> > ERROR: code indent should never use tabs
> > #1157: FILE: tcmu/helper.c:648:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1158: FILE: tcmu/helper.c:649:
> > +^Ielse {$
> > 
> > ERROR: else should follow close brace '}'
> > #1158: FILE: tcmu/helper.c:649:
> > +       }
> > +       else {
> > 
> > ERROR: code indent should never use tabs
> > #1159: FILE: tcmu/helper.c:650:
> > +^I^Iorig_buf[0] = used_len - 1;$
> > 
> > ERROR: code indent should never use tabs
> > #1160: FILE: tcmu/helper.c:651:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1162: FILE: tcmu/helper.c:653:
> > +^Itcmu_memcpy_into_iovec(iovec, iov_cnt, orig_buf, alloc_len);$
> > 
> > ERROR: code indent should never use tabs
> > #1163: FILE: tcmu/helper.c:654:
> > +^Ifree(orig_buf);$
> > 
> > ERROR: code indent should never use tabs
> > #1164: FILE: tcmu/helper.c:655:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #1167: FILE: tcmu/helper.c:658:
> > +^Ifree(orig_buf);$
> > 
> > ERROR: code indent should never use tabs
> > #1169: FILE: tcmu/helper.c:660:
> > +^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1178: FILE: tcmu/helper.c:669:
> > +^Istruct tcmu_device *dev,$
> > 
> > ERROR: code indent should never use tabs
> > #1179: FILE: tcmu/helper.c:670:
> > +^Iuint8_t *cdb,$
> > 
> > ERROR: code indent should never use tabs
> > #1180: FILE: tcmu/helper.c:671:
> > +^Istruct iovec *iovec,$
> > 
> > ERROR: code indent should never use tabs
> > #1181: FILE: tcmu/helper.c:672:
> > +^Isize_t iov_cnt)$
> > 
> > ERROR: code indent should never use tabs
> > #1183: FILE: tcmu/helper.c:674:
> > +^Ibool select_ten = (cdb[0] == MODE_SELECT_10);$
> > 
> > ERROR: code indent should never use tabs
> > #1184: FILE: tcmu/helper.c:675:
> > +^Iuint8_t page_code = cdb[2] & 0x3f;$
> > 
> > ERROR: code indent should never use tabs
> > #1185: FILE: tcmu/helper.c:676:
> > +^Iuint8_t subpage_code = cdb[3];$
> > 
> > ERROR: code indent should never use tabs
> > #1186: FILE: tcmu/helper.c:677:
> > +^Isize_t alloc_len = tcmu_dev_get_max_xfer_len(dev);$
> > 
> > ERROR: code indent should never use tabs
> > #1187: FILE: tcmu/helper.c:678:
> > +^Iint i;$
> > 
> > ERROR: code indent should never use tabs
> > #1188: FILE: tcmu/helper.c:679:
> > +^Iint ret = 0;$
> > 
> > ERROR: code indent should never use tabs
> > #1189: FILE: tcmu/helper.c:680:
> > +^Isize_t hdr_len = select_ten ? 8 : 4;$
> > 
> > ERROR: code indent should never use tabs
> > #1190: FILE: tcmu/helper.c:681:
> > +^Iuint8_t buf[512];$
> > 
> > ERROR: code indent should never use tabs
> > #1191: FILE: tcmu/helper.c:682:
> > +^Iuint8_t in_buf[512];$
> > 
> > ERROR: code indent should never use tabs
> > #1192: FILE: tcmu/helper.c:683:
> > +^Ibool got_sense = false;$
> > 
> > ERROR: code indent should never use tabs
> > #1194: FILE: tcmu/helper.c:685:
> > +^Iif (!alloc_len)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1194: FILE: tcmu/helper.c:685:
> > +       if (!alloc_len)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1195: FILE: tcmu/helper.c:686:
> > +^I^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: line over 90 characters
> > #1197: FILE: tcmu/helper.c:688:
> > +       if (tcmu_memcpy_from_iovec(in_buf, sizeof(in_buf), iovec, iov_cnt) >= sizeof(in_buf))
> > 
> > ERROR: code indent should never use tabs
> > #1197: FILE: tcmu/helper.c:688:
> > +^Iif (tcmu_memcpy_from_iovec(in_buf, sizeof(in_buf), iovec, iov_cnt) >= sizeof(in_buf))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1197: FILE: tcmu/helper.c:688:
> > +       if (tcmu_memcpy_from_iovec(in_buf, sizeof(in_buf), iovec, iov_cnt) >= sizeof(in_buf))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1198: FILE: tcmu/helper.c:689:
> > +^I^Ireturn TCMU_STS_INVALID_PARAM_LIST_LEN;$
> > 
> > ERROR: code indent should never use tabs
> > #1200: FILE: tcmu/helper.c:691:
> > +^I/* Abort if !pf or sp */$
> > 
> > ERROR: code indent should never use tabs
> > #1201: FILE: tcmu/helper.c:692:
> > +^Iif (!(cdb[1] & 0x10) || (cdb[1] & 0x01))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1201: FILE: tcmu/helper.c:692:
> > +       if (!(cdb[1] & 0x10) || (cdb[1] & 0x01))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1202: FILE: tcmu/helper.c:693:
> > +^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1204: FILE: tcmu/helper.c:695:
> > +^Imemset(buf, 0, sizeof(buf));$
> > 
> > ERROR: code indent should never use tabs
> > #1205: FILE: tcmu/helper.c:696:
> > +^Ifor (i = 0; i < ARRAY_SIZE(modesense_handlers); i++) {$
> > 
> > ERROR: code indent should never use tabs
> > #1206: FILE: tcmu/helper.c:697:
> > +^I^Iif (page_code == modesense_handlers[i].page$
> > 
> > ERROR: code indent should never use tabs
> > #1207: FILE: tcmu/helper.c:698:
> > +^I^I    && subpage_code == modesense_handlers[i].subpage) {$
> > 
> > ERROR: code indent should never use tabs
> > #1208: FILE: tcmu/helper.c:699:
> > +^I^I^Iret = modesense_handlers[i].get(dev, &buf[hdr_len],$
> > 
> > ERROR: code indent should never use tabs
> > #1209: FILE: tcmu/helper.c:700:
> > +^I^I^I^I^I^I^Isizeof(buf) - hdr_len);$
> > 
> > ERROR: code indent should never use tabs
> > #1210: FILE: tcmu/helper.c:701:
> > +^I^I^Iif (ret <= 0)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1210: FILE: tcmu/helper.c:701:
> > +                       if (ret <= 0)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1211: FILE: tcmu/helper.c:702:
> > +^I^I^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1213: FILE: tcmu/helper.c:704:
> > +^I^I^Iif  (!select_ten && (hdr_len + ret >= 255))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1213: FILE: tcmu/helper.c:704:
> > +                       if  (!select_ten && (hdr_len + ret >= 255))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1214: FILE: tcmu/helper.c:705:
> > +^I^I^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1216: FILE: tcmu/helper.c:707:
> > +^I^I^Igot_sense = true;$
> > 
> > ERROR: code indent should never use tabs
> > #1217: FILE: tcmu/helper.c:708:
> > +^I^I^Ibreak;$
> > 
> > ERROR: code indent should never use tabs
> > #1218: FILE: tcmu/helper.c:709:
> > +^I^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1219: FILE: tcmu/helper.c:710:
> > +^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1221: FILE: tcmu/helper.c:712:
> > +^Iif (!got_sense)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1221: FILE: tcmu/helper.c:712:
> > +       if (!got_sense)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1222: FILE: tcmu/helper.c:713:
> > +^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1224: FILE: tcmu/helper.c:715:
> > +^Iif (alloc_len < (hdr_len + ret))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1224: FILE: tcmu/helper.c:715:
> > +       if (alloc_len < (hdr_len + ret))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1225: FILE: tcmu/helper.c:716:
> > +^I^Ireturn TCMU_STS_INVALID_PARAM_LIST_LEN;$
> > 
> > ERROR: code indent should never use tabs
> > #1227: FILE: tcmu/helper.c:718:
> > +^I/* Verify what was selected is identical to what sense returns, since we$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1227: FILE: tcmu/helper.c:718:
> > +       /* Verify what was selected is identical to what sense returns, since we
> > 
> > ERROR: code indent should never use tabs
> > #1228: FILE: tcmu/helper.c:719:
> > +^I   don't support actually setting anything. */$
> > 
> > WARNING: Block comments use * on subsequent lines
> > #1228: FILE: tcmu/helper.c:719:
> > +       /* Verify what was selected is identical to what sense returns, since we
> > +          don't support actually setting anything. */
> > 
> > WARNING: Block comments use a trailing */ on a separate line
> > #1228: FILE: tcmu/helper.c:719:
> > +          don't support actually setting anything. */
> > 
> > ERROR: code indent should never use tabs
> > #1229: FILE: tcmu/helper.c:720:
> > +^Iif (memcmp(&buf[hdr_len], &in_buf[hdr_len], ret))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1229: FILE: tcmu/helper.c:720:
> > +       if (memcmp(&buf[hdr_len], &in_buf[hdr_len], ret))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1230: FILE: tcmu/helper.c:721:
> > +^I^Ireturn TCMU_STS_INVALID_PARAM_LIST;$
> > 
> > ERROR: code indent should never use tabs
> > #1232: FILE: tcmu/helper.c:723:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > ERROR: code indent should never use tabs
> > #1237: FILE: tcmu/helper.c:728:
> > +^Iif ((cdb[4] >> 4) & 0xf)$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1237: FILE: tcmu/helper.c:728:
> > +       if ((cdb[4] >> 4) & 0xf)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1238: FILE: tcmu/helper.c:729:
> > +^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1240: FILE: tcmu/helper.c:731:
> > +^I/* Currently, we don't allow ejecting the medium, so we're$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1240: FILE: tcmu/helper.c:731:
> > +       /* Currently, we don't allow ejecting the medium, so we're
> > 
> > ERROR: code indent should never use tabs
> > #1241: FILE: tcmu/helper.c:732:
> > +^I * ignoring the FBO_PREV_EJECT flag, but it may turn out that$
> > 
> > ERROR: code indent should never use tabs
> > #1242: FILE: tcmu/helper.c:733:
> > +^I * initiators do not handle this well, so we may have to change$
> > 
> > ERROR: code indent should never use tabs
> > #1243: FILE: tcmu/helper.c:734:
> > +^I * this behavior.$
> > 
> > ERROR: code indent should never use tabs
> > #1244: FILE: tcmu/helper.c:735:
> > +^I */$
> > 
> > ERROR: code indent should never use tabs
> > #1246: FILE: tcmu/helper.c:737:
> > +^Iif (!(cdb[4] & 0x01))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1246: FILE: tcmu/helper.c:737:
> > +       if (!(cdb[4] & 0x01))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1247: FILE: tcmu/helper.c:738:
> > +^I^Ireturn TCMU_STS_INVALID_CDB;$
> > 
> > ERROR: code indent should never use tabs
> > #1249: FILE: tcmu/helper.c:740:
> > +^Ireturn TCMU_STS_OK;$
> > 
> > WARNING: architecture specific defines should be avoided
> > #1269: FILE: tcmu/helper.h:13:
> > +#ifndef __TCMU_HELPER_H
> > 
> > ERROR: line over 90 characters
> > #1275: FILE: tcmu/helper.h:19:
> > +int tcmu_emulate_inquiry(struct tcmu_device *dev, uint8_t *cdb, struct iovec *iovec, size_t iov_cnt);
> > 
> > WARNING: line over 80 characters
> > #1277: FILE: tcmu/helper.h:21:
> > +int tcmu_emulate_test_unit_ready(uint8_t *cdb, struct iovec *iovec, size_t iov_cnt);
> > 
> > WARNING: line over 80 characters
> > #1278: FILE: tcmu/helper.h:22:
> > +int tcmu_emulate_read_capacity_10(uint64_t num_lbas, uint32_t block_size, uint8_t *cdb,
> > 
> > ERROR: code indent should never use tabs
> > #1279: FILE: tcmu/helper.h:23:
> > +^I^I^I^I  struct iovec *iovec, size_t iov_cnt);$
> > 
> > WARNING: line over 80 characters
> > #1280: FILE: tcmu/helper.h:24:
> > +int tcmu_emulate_read_capacity_16(uint64_t num_lbas, uint32_t block_size, uint8_t *cdb,
> > 
> > ERROR: code indent should never use tabs
> > #1281: FILE: tcmu/helper.h:25:
> > +^I^I^I^I  struct iovec *iovec, size_t iov_cnt);$
> > 
> > ERROR: code indent should never use tabs
> > #1283: FILE: tcmu/helper.h:27:
> > +^I^I^I    struct iovec *iovec, size_t iov_cnt);$
> > 
> > ERROR: code indent should never use tabs
> > #1285: FILE: tcmu/helper.h:29:
> > +^I^I^I     struct iovec *iovec, size_t iov_cnt);$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1514: FILE: tcmu/tcmu.c:221:
> > +        { /* end of list */ }
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1523: FILE: tcmu/tcmu.c:230:
> > +        { /* end of list */ }
> > 
> > ERROR: do not use assignment in if condition
> > #1590: FILE: tcmu/tcmu.c:297:
> > +    if ((aio = qemu_opt_get(common_opts, "aio")) != NULL) {
> > 
> > ERROR: do not use assignment in if condition
> > #1602: FILE: tcmu/tcmu.c:309:
> > +    if ((buf = qemu_opt_get(common_opts, "format")) != NULL) {
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1617: FILE: tcmu/tcmu.c:324:
> > +    if (read_only)
> > [...]
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1620: FILE: tcmu/tcmu.c:327:
> > +    /* bdrv_open() defaults to the values in bdrv_flags (for compatibility
> > 
> > WARNING: Block comments use a trailing */ on a separate line
> > #1622: FILE: tcmu/tcmu.c:329:
> > +     * Apply the defaults here instead. */
> > 
> > ERROR: space required before the open parenthesis '('
> > #1712: FILE: tcmu/tcmu.c:419:
> > +    if(exp)
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1712: FILE: tcmu/tcmu.c:419:
> > +    if(exp)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1761: FILE: tcmu/tcmu.c:468:
> > +^Iid = device;$
> > 
> > ERROR: code indent should never use tabs
> > #1762: FILE: tcmu/tcmu.c:469:
> > +    ^Iblk = blk_by_name(id);$
> > 
> > ERROR: code indent should never use tabs
> > #1763: FILE: tcmu/tcmu.c:470:
> > +    ^Iif (!blk) {$
> > 
> > ERROR: code indent should never use tabs
> > #1764: FILE: tcmu/tcmu.c:471:
> > +        ^Ierror_setg(errp, "TCMU: Device not found: %s", id);$
> > 
> > ERROR: code indent should never use tabs
> > #1765: FILE: tcmu/tcmu.c:472:
> > +        ^Ireturn false;$
> > 
> > ERROR: code indent should never use tabs
> > #1766: FILE: tcmu/tcmu.c:473:
> > +    ^I}$
> > 
> > ERROR: code indent should never use tabs
> > #1767: FILE: tcmu/tcmu.c:474:
> > +    ^Iexp = tcmu_export_lookup(blk);$
> > 
> > ERROR: code indent should never use tabs
> > #1768: FILE: tcmu/tcmu.c:475:
> > +    ^Iif (!exp) {$
> > 
> > ERROR: code indent should never use tabs
> > #1769: FILE: tcmu/tcmu.c:476:
> > +        ^Ierror_setg(errp, "TCMU: Device not found: %s", id);$
> > 
> > ERROR: code indent should never use tabs
> > #1770: FILE: tcmu/tcmu.c:477:
> > +        ^Ireturn false;$
> > 
> > ERROR: code indent should never use tabs
> > #1771: FILE: tcmu/tcmu.c:478:
> > +   ^I}$
> > 
> > ERROR: do not use C99 // comments
> > #1772: FILE: tcmu/tcmu.c:479:
> > +    }// TODO: else to check id?
> > 
> > ERROR: code indent should never use tabs
> > #1780: FILE: tcmu/tcmu.c:487:
> > +^Iif (*opts == '@') {$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1780: FILE: tcmu/tcmu.c:487:
> > +       if (*opts == '@') {
> > [...]
> > +       } else
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1781: FILE: tcmu/tcmu.c:488:
> > +^I    *to = ',';$
> > 
> > ERROR: code indent should never use tabs
> > #1782: FILE: tcmu/tcmu.c:489:
> > +^I} else$
> > 
> > ERROR: code indent should never use tabs
> > #1783: FILE: tcmu/tcmu.c:490:
> > +^I    *to = *opts;$
> > 
> > ERROR: code indent should never use tabs
> > #1785: FILE: tcmu/tcmu.c:492:
> > +^Iopts++;$
> > 
> > ERROR: code indent should never use tabs
> > #1786: FILE: tcmu/tcmu.c:493:
> > +^Ito++;$
> > 
> > ERROR: space required before the open parenthesis '('
> > #1789: FILE: tcmu/tcmu.c:496:
> > +    if(to)
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1789: FILE: tcmu/tcmu.c:496:
> > +    if(to)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1806: FILE: tcmu/tcmu.c:513:
> > +    ^Iid = device;$
> > 
> > ERROR: code indent should never use tabs
> > #1807: FILE: tcmu/tcmu.c:514:
> > +    ^Iexp = tcmu_export_lookup(blk_by_name(id));$
> > 
> > ERROR: else should follow close brace '}'
> > #1809: FILE: tcmu/tcmu.c:516:
> > +    }
> > +    else {
> > 
> > ERROR: code indent should never use tabs
> > #1810: FILE: tcmu/tcmu.c:517:
> > +^IQemuOpts * export_opts;$
> > 
> > ERROR: "foo * bar" should be "foo *bar"
> > #1810: FILE: tcmu/tcmu.c:517:
> > +       QemuOpts * export_opts;
> > 
> > ERROR: code indent should never use tabs
> > #1812: FILE: tcmu/tcmu.c:519:
> > +^Inew_device = g_malloc0(strlen(device) + 1);$
> > 
> > ERROR: code indent should never use tabs
> > #1813: FILE: tcmu/tcmu.c:520:
> > +^Itcmu_convert_delim(new_device, device);$
> > 
> > WARNING: Block comments use a leading /* on a separate line
> > #1815: FILE: tcmu/tcmu.c:522:
> > +        /* parse new_device into an QemuOpts and link into
> > 
> > WARNING: Block comments use * on subsequent lines
> > #1816: FILE: tcmu/tcmu.c:523:
> > +        /* parse new_device into an QemuOpts and link into
> > +           qemu_tcmu_export_opts with QemuOpts->id set while
> > 
> > ERROR: code indent should never use tabs
> > #1819: FILE: tcmu/tcmu.c:526:
> > +^Iexport_opts = qemu_opts_parse_noisily(&qemu_tcmu_export_opts,$
> > 
> > ERROR: code indent should never use tabs
> > #1820: FILE: tcmu/tcmu.c:527:
> > +^I^I^I^I^I    new_device, false);$
> > 
> > ERROR: space required before the open parenthesis '('
> > #1824: FILE: tcmu/tcmu.c:531:
> > +        if(!export_opts)
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1824: FILE: tcmu/tcmu.c:531:
> > +        if(!export_opts)
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1827: FILE: tcmu/tcmu.c:534:
> > +^Iif (export_init_func(NULL, export_opts, NULL))$
> > 
> > ERROR: braces {} are necessary for all arms of this statement
> > #1827: FILE: tcmu/tcmu.c:534:
> > +       if (export_init_func(NULL, export_opts, NULL))
> > [...]
> > 
> > ERROR: code indent should never use tabs
> > #1828: FILE: tcmu/tcmu.c:535:
> > +^I    goto fail;$
> > 
> > ERROR: code indent should never use tabs
> > #1830: FILE: tcmu/tcmu.c:537:
> > +^Iid = qemu_opts_id(export_opts);$
> > 
> > ERROR: code indent should never use tabs
> > #1831: FILE: tcmu/tcmu.c:538:
> > +^Iexp = tcmu_export_lookup(blk_by_name(id));$
> > 
> > total: 620 errors, 26 warnings, 1809 lines checked
> > 
> > Your patch has style problems, please review.  If any of these errors
> > are false positives report them to the maintainer, see
> > CHECKPATCH in MAINTAINERS.
> > 
> > === OUTPUT END ===
> > 
> > Test command exited with code: 1
> > 
> > 
> > The full log is available at
> > http://patchew.org/logs/1545387387-9613-1-git-send-email-baiyaowei@cmss.chinamobile.com/testing.checkpatch/?type=message.
> > ---
> > Email generated automatically by Patchew [http://patchew.org/].
> > Please send your feedback to patchew-devel@redhat.com

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

* [Qemu-devel] (no subject)
@ 2018-12-13 10:10 Илья Резников
  0 siblings, 0 replies; 133+ messages in thread
From: Илья Резников @ 2018-12-13 10:10 UTC (permalink / raw)
  To: qemu-devel

Please add android support

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

* Re: [Qemu-devel] (no subject)
  2018-11-29  2:11     ` berkus infinitus
@ 2018-11-29 10:18       ` Peter Maydell
  0 siblings, 0 replies; 133+ messages in thread
From: Peter Maydell @ 2018-11-29 10:18 UTC (permalink / raw)
  To: Berkus Decker; +Cc: G 3, QEMU Developers

On Thu, 29 Nov 2018 at 02:11, berkus infinitus <berkus@gmail.com> wrote:
>
> I suspect the main problem is the blocking call to qemu_main
> from the UI thread in the app delegate didFinishLoadingWithOptions
> if i’m not mistaken and everything else grows from there.

Yes; if there's no way that Mojave will allow us to run
qemu_main directly on the main thread, then we have to
create a 2nd thread to run qemu_main on (which then becomes
what QEMU thinks of as the "main loop thread"), and then
we run into the need to make all the UI calls be forwarded
from the main loop thread to the main thread, and to get
QEMU locks when making calls into qemu from the main thread.

I think the code we have in git currently will already do
all the UI calls on the main thread -- it just does it by
doing a blocking call into qemu_main which later does
event processing itself. (It's a shame OSX doesn't document
what you need to do to write code that way, it's a fairly
common paradigm for other GUIs.)

For High Sierra there is apparently a "main thread checker"
utility: https://developer.apple.com/documentation/code_diagnostics/main_thread_checker
so running
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libMainThreadChecker.dylib
qemu-system-x86_64 args...

will let us check for violations of the "do things on main
thread" principle even without Mohave. For me with current
QEMU it doesn't report any issues.

thanks
-- PMM

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

* Re: [Qemu-devel] (no subject)
  2018-11-29  0:21   ` Programmingkid
@ 2018-11-29  2:11     ` berkus infinitus
  2018-11-29 10:18       ` Peter Maydell
  0 siblings, 1 reply; 133+ messages in thread
From: berkus infinitus @ 2018-11-29  2:11 UTC (permalink / raw)
  To: Programmingkid; +Cc: Peter Maydell, QEMU Developers

I suspect the main problem is the blocking call to qemu_main from the UI
thread in the app delegate didFinishLoadingWithOptions if i’m not mistaken
and everything else grows from there. Going to build and run it now, since
I woke up in the middle of the night anyway for reasons unexplainable)
On Thu, 29 Nov 2018 at 02:21, Programmingkid <programmingkidx@gmail.com>
wrote:

>
> > On Nov 28, 2018, at 2:39 PM, Peter Maydell <peter.maydell@linaro.org>
> wrote:
> >
> > On Wed, 28 Nov 2018 at 01:12, John Arbuckle <programmingkidx@gmail.com>
> wrote:
> >>
> >> From af4497f2b161bb4165acb8eee5cae3f2a7ea2227 Mon Sep 17 00:00:00 2001
> >> From: John Arbuckle <programmingkidx@gmail.com>
> >> Date: Tue, 27 Nov 2018 20:01:20 -0500
> >> Subject: [PATCH] ui/cocoa.m: fix crash due to cocoa_refresh() on Mac OS
> 10.14
> >
> > Something seems to have got the formatting of this patch email
> > wrong -- it's got all this in the body and the actual Subject
> > line of the email is blank.
>
> I don't know what happened.
>
> >
> >> Mac OS 10.14 only wants UI code to be called from the main thread. The
> >> cocoa_refresh() function is called on another thread and this causes a
> >> crash to take place. To fix this problem the cocoa_refresh() code is
> >> called from the main thread only.
> >>
> >> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> >> ---
> >> ui/cocoa.m | 59
> ++++++++++++++++++++++++++++++++++-------------------------
> >> 1 file changed, 34 insertions(+), 25 deletions(-)
> >
> > I get a compile warning with this patch:
> > /Users/pm215/src/qemu/ui/cocoa.m:1615:23: warning: instance method
> > '-cocoa_refresh' not found (return type defaults to 'id')
> > [-Wobjc-method-access]
> >    [[NSApp delegate] cocoa_refresh];
> >                      ^~~~~~~~~~~~~
>
> This will fix the problem:
>
> static void cocoa_refresh(DisplayChangeListener *dcl)
> {
>     QemuCocoaAppController *controller = (QemuCocoaAppController *)[NSApp
> delegate];
>     [controller cocoa_refresh];
> }
>
> > To be honest, I'm still confused about what is causing the
> > problems on Mojave. The refresh method should be being called
> > on the main thread even with the code on master -- it's just
> > that that is the iothread and it's running the event pumping
> > code in the refresh callback rather than a standard OSX
> > event loop. I'm hoping that the backtrace with symbols of
> > the Mojave assertion failure will help there, since I
> > can't currently see where refresh gets called from some
> > non-main thread.
>
> This might be a Mojave issue and not a QEMU issue.
> I'm on Mac OS 10.12 so I can't confirm anything.
>
> > I also think that this patch doesn't address the problems
> > of locking that I mention on the discussion thread for
> > Berkus' patch. It also doesn't handle any of the other
> > callbacks from QEMU to the cocoa UI -- surely we need to
> > handle all of them if there is a problem here?
>
> To answer this question I would have to know how my patch
> does on Mac OS 10.14. Does it stop the crashing issue? If
> this patch does fix that problem then I think sticking to
> a simple solution may be the answer. The use of locks may
> not be needed.
>
> > (I have some prototype patches which I've been working
> > on which address the locking problem and also make all
> > the QEMU callbacks run their work on the main thread.
> > I may be able get those into shape to post those next week.)
>
> Please CC me when do release it. I will test it on Mac OS 10.12
> and Mac OS 10.6.

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

* Re: [Qemu-devel] (no subject)
  2018-11-28 19:39 ` Peter Maydell
@ 2018-11-29  0:21   ` Programmingkid
  2018-11-29  2:11     ` berkus infinitus
  0 siblings, 1 reply; 133+ messages in thread
From: Programmingkid @ 2018-11-29  0:21 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Berkus Decker, QEMU Developers


> On Nov 28, 2018, at 2:39 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> On Wed, 28 Nov 2018 at 01:12, John Arbuckle <programmingkidx@gmail.com> wrote:
>> 
>> From af4497f2b161bb4165acb8eee5cae3f2a7ea2227 Mon Sep 17 00:00:00 2001
>> From: John Arbuckle <programmingkidx@gmail.com>
>> Date: Tue, 27 Nov 2018 20:01:20 -0500
>> Subject: [PATCH] ui/cocoa.m: fix crash due to cocoa_refresh() on Mac OS 10.14
> 
> Something seems to have got the formatting of this patch email
> wrong -- it's got all this in the body and the actual Subject
> line of the email is blank.

I don't know what happened.

> 
>> Mac OS 10.14 only wants UI code to be called from the main thread. The
>> cocoa_refresh() function is called on another thread and this causes a
>> crash to take place. To fix this problem the cocoa_refresh() code is
>> called from the main thread only.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> ---
>> ui/cocoa.m | 59 ++++++++++++++++++++++++++++++++++-------------------------
>> 1 file changed, 34 insertions(+), 25 deletions(-)
> 
> I get a compile warning with this patch:
> /Users/pm215/src/qemu/ui/cocoa.m:1615:23: warning: instance method
> '-cocoa_refresh' not found (return type defaults to 'id')
> [-Wobjc-method-access]
>    [[NSApp delegate] cocoa_refresh];
>                      ^~~~~~~~~~~~~

This will fix the problem:

static void cocoa_refresh(DisplayChangeListener *dcl)
{
    QemuCocoaAppController *controller = (QemuCocoaAppController *)[NSApp delegate];
    [controller cocoa_refresh];
}

> To be honest, I'm still confused about what is causing the
> problems on Mojave. The refresh method should be being called
> on the main thread even with the code on master -- it's just
> that that is the iothread and it's running the event pumping
> code in the refresh callback rather than a standard OSX
> event loop. I'm hoping that the backtrace with symbols of
> the Mojave assertion failure will help there, since I
> can't currently see where refresh gets called from some
> non-main thread.

This might be a Mojave issue and not a QEMU issue. 
I'm on Mac OS 10.12 so I can't confirm anything.

> I also think that this patch doesn't address the problems
> of locking that I mention on the discussion thread for
> Berkus' patch. It also doesn't handle any of the other
> callbacks from QEMU to the cocoa UI -- surely we need to
> handle all of them if there is a problem here?

To answer this question I would have to know how my patch
does on Mac OS 10.14. Does it stop the crashing issue? If
this patch does fix that problem then I think sticking to
a simple solution may be the answer. The use of locks may
not be needed.

> (I have some prototype patches which I've been working
> on which address the locking problem and also make all
> the QEMU callbacks run their work on the main thread.
> I may be able get those into shape to post those next week.)

Please CC me when do release it. I will test it on Mac OS 10.12
and Mac OS 10.6. 

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

* Re: [Qemu-devel] (no subject)
  2018-11-28  1:08 John Arbuckle
@ 2018-11-28 19:39 ` Peter Maydell
  2018-11-29  0:21   ` Programmingkid
  0 siblings, 1 reply; 133+ messages in thread
From: Peter Maydell @ 2018-11-28 19:39 UTC (permalink / raw)
  To: G 3; +Cc: Berkus Decker, QEMU Developers

On Wed, 28 Nov 2018 at 01:12, John Arbuckle <programmingkidx@gmail.com> wrote:
>
> From af4497f2b161bb4165acb8eee5cae3f2a7ea2227 Mon Sep 17 00:00:00 2001
> From: John Arbuckle <programmingkidx@gmail.com>
> Date: Tue, 27 Nov 2018 20:01:20 -0500
> Subject: [PATCH] ui/cocoa.m: fix crash due to cocoa_refresh() on Mac OS 10.14

Something seems to have got the formatting of this patch email
wrong -- it's got all this in the body and the actual Subject
line of the email is blank.

> Mac OS 10.14 only wants UI code to be called from the main thread. The
> cocoa_refresh() function is called on another thread and this causes a
> crash to take place. To fix this problem the cocoa_refresh() code is
> called from the main thread only.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
>  ui/cocoa.m | 59 ++++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 34 insertions(+), 25 deletions(-)

I get a compile warning with this patch:
/Users/pm215/src/qemu/ui/cocoa.m:1615:23: warning: instance method
'-cocoa_refresh' not found (return type defaults to 'id')
[-Wobjc-method-access]
    [[NSApp delegate] cocoa_refresh];
                      ^~~~~~~~~~~~~

To be honest, I'm still confused about what is causing the
problems on Mojave. The refresh method should be being called
on the main thread even with the code on master -- it's just
that that is the iothread and it's running the event pumping
code in the refresh callback rather than a standard OSX
event loop. I'm hoping that the backtrace with symbols of
the Mojave assertion failure will help there, since I
can't currently see where refresh gets called from some
non-main thread.

I also think that this patch doesn't address the problems
of locking that I mention on the discussion thread for
Berkus' patch. It also doesn't handle any of the other
callbacks from QEMU to the cocoa UI -- surely we need to
handle all of them if there is a problem here?

(I have some prototype patches which I've been working
on which address the locking problem and also make all
the QEMU callbacks run their work on the main thread.
I may be able get those into shape to post those next week.)

thanks
-- PMM

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

* [Qemu-devel] (no subject)
@ 2018-11-28  1:08 John Arbuckle
  2018-11-28 19:39 ` Peter Maydell
  0 siblings, 1 reply; 133+ messages in thread
From: John Arbuckle @ 2018-11-28  1:08 UTC (permalink / raw)
  To: peter.maydell, berkus, qemu-devel; +Cc: John Arbuckle

>From af4497f2b161bb4165acb8eee5cae3f2a7ea2227 Mon Sep 17 00:00:00 2001
From: John Arbuckle <programmingkidx@gmail.com>
Date: Tue, 27 Nov 2018 20:01:20 -0500
Subject: [PATCH] ui/cocoa.m: fix crash due to cocoa_refresh() on Mac OS 10.14

Mac OS 10.14 only wants UI code to be called from the main thread. The
cocoa_refresh() function is called on another thread and this causes a
crash to take place. To fix this problem the cocoa_refresh() code is
called from the main thread only. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 ui/cocoa.m | 59 ++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 25 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index ecf12bfc2e..17c168d08f 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -972,6 +972,8 @@ - (void)openDocumentation:(NSString *)filename;
 - (IBAction) do_about_menu_item: (id) sender;
 - (void)make_about_window;
 - (void)adjustSpeed:(id)sender;
+- (void) cocoa_refresh;
+- (void) cocoa_refresh_internal: (id) dummy;
 @end
 
 @implementation QemuCocoaAppController
@@ -1406,6 +1408,37 @@ - (void)adjustSpeed:(id)sender
     COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(), '%');
 }
 
+- (void) cocoa_refresh
+{
+    [self performSelectorOnMainThread: @selector(cocoa_refresh_internal:) withObject: nil waitUntilDone: YES];
+}
+
+- (void) cocoa_refresh_internal: (id) dummy
+{
+    COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
+    graphic_hw_update(NULL);
+
+    if (qemu_input_is_absolute()) {
+        if (![cocoaView isAbsoluteEnabled]) {
+            if ([cocoaView isMouseGrabbed]) {
+                [cocoaView ungrabMouse];
+            }
+        }
+        [cocoaView setAbsoluteEnabled:YES];
+    }
+
+    NSDate *distantPast;
+    NSEvent *event;
+    distantPast = [NSDate distantPast];
+    do {
+        event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:distantPast
+                                      inMode: NSDefaultRunLoopMode dequeue:YES];
+        if (event != nil) {
+            [cocoaView handleEvent:event];
+        }
+    } while(event != nil);
+}
+
 @end
 
 
@@ -1579,31 +1612,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
 
 static void cocoa_refresh(DisplayChangeListener *dcl)
 {
-    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-
-    COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
-    graphic_hw_update(NULL);
-
-    if (qemu_input_is_absolute()) {
-        if (![cocoaView isAbsoluteEnabled]) {
-            if ([cocoaView isMouseGrabbed]) {
-                [cocoaView ungrabMouse];
-            }
-        }
-        [cocoaView setAbsoluteEnabled:YES];
-    }
-
-    NSDate *distantPast;
-    NSEvent *event;
-    distantPast = [NSDate distantPast];
-    do {
-        event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:distantPast
-                        inMode: NSDefaultRunLoopMode dequeue:YES];
-        if (event != nil) {
-            [cocoaView handleEvent:event];
-        }
-    } while(event != nil);
-    [pool release];
+    [[NSApp delegate] cocoa_refresh];
 }
 
 static void cocoa_cleanup(void)
-- 
2.14.3 (Apple Git-98)

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

* [Qemu-devel] (no subject)
@ 2018-07-22  9:13 Liujinsong (Paul)
  0 siblings, 0 replies; 133+ messages in thread
From: Liujinsong (Paul) @ 2018-07-22  9:13 UTC (permalink / raw)
  To: qemu-devel



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

* [Qemu-devel] (no subject)
  2018-06-20  7:32 [Qemu-devel] [PATCH v5 0/7] monitor: enable OOB by default Peter Xu
@ 2018-06-26 17:21 ` Markus Armbruster
  0 siblings, 0 replies; 133+ messages in thread
From: Markus Armbruster @ 2018-06-26 17:21 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-devel

I fooled around a bit, and I think there are a few lose ends.

Lets update the examples in docs/interop/qmp-spec.txt to show the
current greeting (section 3.1) and how to accept a capability (section
3.2).  The capability negotiation documentation could use some polish.
I'll post a patch.

Talking to a QMP monitor that supports OOB:

    $ socat UNIX:test-qmp READLINE,history=$HOME/.qmp_history,prompt='QMP> '
    {"QMP": {"version": {"qemu": {"micro": 50, "minor": 12, "major": 2}, "package": "v2.12.0-1703-gb909799463"}, "capabilities": ["oob"]}}
    QMP> { "execute": "qmp_capabilities", "arguments": { "oob": true } }
    {"error": {"class": "GenericError", "desc": "Parameter 'oob' is unexpected"}}
    QMP> { "execute": "qmp_capabilities", "arguments": { "enable": ["oob"] } }
    {"return": {}}
    QMP> { "execute": "query-qmp-schema" }
    {"error": {"class": "GenericError", "desc": "Out-Of-Band capability requires that every command contains an 'id' field"}}

Why does every command require 'id'?

Talking to a QMP monitor that doesn't support OOB:

    {"QMP": {"version": {"qemu": {"micro": 50, "minor": 12, "major": 2}, "package": "v2.12.0-1703-gb909799463"}, "capabilities": []}}
    QMP> { "execute": "qmp_capabilities", "arguments": { "enable": ["oob"] } }
    {"error": {"class": "GenericError", "desc": "This monitor does not support Out-Of-Band (OOB)"}}
    QMP> { "execute": "qmp_capabilities" }
    {"return": {}}
    QMP> { "execute": "query-kvm" }
    {"return": {"enabled": true, "present": true}}
    QMP> { "execute": "query-kvm", "control": { "run-oob": true } }
    {"error": {"class": "GenericError", "desc": "Please enable Out-Of-Band first for the session during capabilities negotiation"}}

Telling people to enable OOB when that cannot be done is suboptimal.
More so when it cannot be used here anyway.  I'll post a patch.

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

* [Qemu-devel] (no subject)
@ 2017-10-12 23:54 Anatol Pomozov
  0 siblings, 0 replies; 133+ messages in thread
From: Anatol Pomozov @ 2017-10-12 23:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, rth, ehabkost, pbonzini, agraf




It is V3 of multiboot improvements to Qemu

Changes made sinse V2:
 - rebase on top of qemu master changes
 - make multiboot/sections test more reliable
     Add generate_sections_out.py script that generates ELF sections information
 - rename 'struct section_data' to 'struct SectionData' to match naming
     convention in include/hw/loader.h

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

* [Qemu-devel] (no subject)
@ 2017-08-07 16:34 Eduardo Otubo
  0 siblings, 0 replies; 133+ messages in thread
From: Eduardo Otubo @ 2017-08-07 16:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: zhang.zhanghailiang, wency

zhangchen.fnst@cn.fujitsu.com, wang.guang55@zte.com.cn,
wang.yong155@zte.com.cn 
Bcc: 
Subject: colo-compare: segfault and assert on colo_compare_finalize
Reply-To: 

Hi all,

I have found a problem on colo-compare that leads to segmentation fault
when calling qemu like this:

 $ qemu-system-x86_64 -S -machine pc -object colo-compare,id=test-object

First I got an assert failed:

 (qemu-system-x86_64:7887): GLib-CRITICAL **: g_main_loop_quit: assertion 'loop != NULL' failed

>From this looks like s->compare_loop is NULL on the function
colo_compare_finalize(), then I just added a check there and the assert went
away. But then there's the segfault:

 Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
 0x00007ffff333f79e in pthread_join () from /lib64/libpthread.so.0
 (gdb) bt
 #0  0x00007ffff333f79e in pthread_join () at /lib64/libpthread.so.0
 #1  0x0000555555c379d2 in qemu_thread_join (thread=0x7ffff7ff5160) at util/qemu-thread-posix.c:547
 #2  0x0000555555adfc1a in colo_compare_finalize (obj=0x7ffff7fd3010) at net/colo-compare.c:867
 #3  0x0000555555b2cd87 in object_deinit (obj=0x7ffff7fd3010, type=0x5555567432e0) at qom/object.c:453
 #4  0x0000555555b2cdf9 in object_finalize (data=0x7ffff7fd3010) at qom/object.c:467
 #5  0x0000555555b2dd80 in object_unref (obj=0x7ffff7fd3010) at qom/object.c:902
 #6  0x0000555555b319a5 in user_creatable_add_type (type=0x5555567499a0 "colo-compare", id=0x555556749960 "test-object", qdict=0x555556835750, v=0x55555681a3f0, errp=0x7fffffffde58) at qom/object_interfaces.c:105
 #7  0x0000555555b31b02 in user_creatable_add_opts (opts=0x555556749910, errp=0x7fffffffde58) at qom/object_interfaces.c:135
 #8  0x0000555555b31bfd in user_creatable_add_opts_foreach (opaque=0x5555558e9c39 <object_create_delayed>, opts=0x555556749910, errp=0x0) at qom/object_interfaces.c:159
 #9  0x0000555555c4aecf in qemu_opts_foreach (list=0x555556157ac0 <qemu_object_opts>, func=0x555555b31b6f <user_creatable_add_opts_foreach>, opaque=0x5555558e9c39 <object_create_delayed>, errp=0x0) at util/qemu-option.c:1104
 #10 0x00005555558edb75 in main (argc=6, argv=0x7fffffffe2d8, envp=0x7fffffffe310) at vl.c:4520

At this point '&s->thread' is '0'. Is this segfault and the above mentioned
assert trigged because I'm creating a colo-compare object without any other
parameter? In a positive case, a simple workaround and error check should do
it. Otherwise I'll debug a little more.

Best regards,

-- 
Eduardo Otubo
Senior Software Engineer @ RedHat

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

* [Qemu-devel] (no subject)
@ 2017-08-07 13:31 vaibhav shukla
  0 siblings, 0 replies; 133+ messages in thread
From: vaibhav shukla @ 2017-08-07 13:31 UTC (permalink / raw)
  To: qemu-devel

Hello,

I am Vaibhav Shukla, sophomore student of Indian Institute of Information Technology, Kalyani, India.

I would like to contribute in some projects in your company, please guide me that how can I do so.

I shall be highly grateful to you.

Yours Sincerely

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

* Re: [Qemu-devel] (no subject)
  2017-05-17 22:42 John Bradley
  2017-05-18  5:29 ` no-reply
@ 2017-05-18  5:31 ` no-reply
  1 sibling, 0 replies; 133+ messages in thread
From: no-reply @ 2017-05-18  5:31 UTC (permalink / raw)
  To: flytart; +Cc: famz, qemu-devel, flypie, peter.maydell, qemu-arm

Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] (no subject)
Type: series
Message-id: 536fb79a-5753-4143-a5a6-7a189ef5137e@ONE.local

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
32d5d78 (no subject)

=== OUTPUT BEGIN ===
Checking PATCH 1/1: (no subject)...
ERROR: space prohibited before that '++' (ctx:WxB)
#34: FILE: hw/gpio/bcm2835_gpio.c:58:
+    for (i = 0; i < 10; i ++) {
                           ^

ERROR: space prohibited between function name and open parenthesis '('
#37: FILE: hw/gpio/bcm2835_gpio.c:60:
+        if (index < sizeof (s->fsel)) {

ERROR: space prohibited before that '++' (ctx:WxB)
#46: FILE: hw/gpio/bcm2835_gpio.c:70:
+    for (i = 0; i < 10; i ++) {
                           ^

ERROR: space prohibited between function name and open parenthesis '('
#49: FILE: hw/gpio/bcm2835_gpio.c:72:
+        if (index < sizeof (s->fsel)) {

ERROR: space prohibited after that '~' (ctx:WxW)
#100: FILE: hw/gpio/bcm2835_gpio.c:115:
+    uint32_t changes = val & ~ *lev;
                              ^

ERROR: space prohibited before that '++' (ctx:WxB)
#105: FILE: hw/gpio/bcm2835_gpio.c:119:
+    for (i = 0; i < count; i ++) {
                              ^

ERROR: space prohibited before that '++' (ctx:WxB)
#121: FILE: hw/gpio/bcm2835_gpio.c:136:
+    for (i = 0; i < count; i ++) {
                              ^

ERROR: space prohibited after that '~' (ctx:WxW)
#129: FILE: hw/gpio/bcm2835_gpio.c:143:
+    *lev &= ~ val;
             ^

ERROR: switch and case should be at the same indent
#141: FILE: hw/gpio/bcm2835_gpio.c:152:
     switch (offset) {
+        case GPFSEL0:
+        case GPFSEL1:
+        case GPFSEL2:
+        case GPFSEL3:
+        case GPFSEL4:
+        case GPFSEL5:
[...]
+        case GPSET0:
+        case GPSET1:
[...]
+        case GPCLR0:
+        case GPCLR1:
[...]
+        case GPLEV0:
[...]
+        case GPLEV1:
[...]
+        case GPEDS0:
+        case GPEDS1:
+        case GPREN0:
+        case GPREN1:
+        case GPFEN0:
+        case GPFEN1:
+        case GPHEN0:
+        case GPHEN1:
+        case GPLEN0:
+        case GPLEN1:
+        case GPAREN0:
+        case GPAREN1:
+        case GPAFEN0:
+        case GPAFEN1:
+        case GPPUD:
+        case GPPUDCLK0:
+        case GPPUDCLK1:
[...]
+        default:

ERROR: space prohibited after that '-' (ctx:WxW)
#200: FILE: hw/gpio/bcm2835_gpio.c:169:
+            if (s->panel.socket != - 1) {
                                    ^

ERROR: space prohibited after that '-' (ctx:WxW)
#208: FILE: hw/gpio/bcm2835_gpio.c:177:
+            if (s->panel.socket != - 1) {
                                    ^

ERROR: switch and case should be at the same indent
#252: FILE: hw/gpio/bcm2835_gpio.c:219:
     switch (offset) {
+        case GPFSEL0:
+        case GPFSEL1:
+        case GPFSEL2:
+        case GPFSEL3:
+        case GPFSEL4:
+        case GPFSEL5:
[...]
+        case GPSET0:
[...]
+        case GPSET1:
[...]
+        case GPCLR0:
[...]
+        case GPCLR1:
[...]
+        case GPLEV0:
+        case GPLEV1:
[...]
+        case GPEDS0:
+        case GPEDS1:
+        case GPREN0:
+        case GPREN1:
+        case GPFEN0:
+        case GPFEN1:
+        case GPHEN0:
+        case GPHEN1:
+        case GPLEN0:
+        case GPLEN1:
+        case GPAREN0:
+        case GPAREN1:
+        case GPAFEN0:
+        case GPAFEN1:
+        case GPPUD:
+        case GPPUDCLK0:
+        case GPPUDCLK1:
[...]
+        default:

ERROR: space prohibited after that '-' (ctx:WxW)
#308: FILE: hw/gpio/bcm2835_gpio.c:230:
+            if (s->panel.socket != - 1) {
                                    ^

WARNING: line over 80 characters
#310: FILE: hw/gpio/bcm2835_gpio.c:232:
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel

ERROR: do not use C99 // comments
#310: FILE: hw/gpio/bcm2835_gpio.c:232:
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel

ERROR: space prohibited after that '-' (ctx:WxW)
#315: FILE: hw/gpio/bcm2835_gpio.c:237:
+            if (s->panel.socket != - 1) {
                                    ^

WARNING: line over 80 characters
#318: FILE: hw/gpio/bcm2835_gpio.c:240:
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel

ERROR: do not use C99 // comments
#318: FILE: hw/gpio/bcm2835_gpio.c:240:
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel

ERROR: space prohibited after that '-' (ctx:WxW)
#323: FILE: hw/gpio/bcm2835_gpio.c:245:
+            if (s->panel.socket != - 1) {
                                    ^

WARNING: line over 80 characters
#325: FILE: hw/gpio/bcm2835_gpio.c:247:
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel

ERROR: do not use C99 // comments
#325: FILE: hw/gpio/bcm2835_gpio.c:247:
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel

ERROR: space prohibited after that '-' (ctx:WxW)
#330: FILE: hw/gpio/bcm2835_gpio.c:252:
+            if (s->panel.socket != - 1) {
                                    ^

WARNING: line over 80 characters
#333: FILE: hw/gpio/bcm2835_gpio.c:255:
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel

ERROR: do not use C99 // comments
#333: FILE: hw/gpio/bcm2835_gpio.c:255:
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel

ERROR: space prohibited before that '++' (ctx:WxB)
#376: FILE: hw/gpio/bcm2835_gpio.c:296:
+    for (i = 0; i < 6; i ++) {
                          ^

WARNING: line over 80 characters
#389: FILE: hw/gpio/bcm2835_gpio.c:312:
+                                                 .endianness = DEVICE_NATIVE_ENDIAN,

WARNING: line over 80 characters
#405: FILE: hw/gpio/bcm2835_gpio.c:319:
+                                                        .fields = (VMStateField[])

ERROR: space prohibited between function name and open parenthesis '('
#420: FILE: hw/gpio/bcm2835_gpio.c:335:
+    qbus_create_inplace(&s->sdbus, sizeof (s->sdbus),

ERROR: do not use C99 // comments
#431: FILE: hw/gpio/bcm2835_gpio.c:345:
+        sendpincount(&s->panel, 54); //PI Has 54 Pins

WARNING: line over 80 characters
#432: FILE: hw/gpio/bcm2835_gpio.c:346:
+        sendenabledmap(&s->panel, 0x003FFFFFFFFFFFFC); //Pins 0 & 1 are I2C so disable

ERROR: do not use C99 // comments
#432: FILE: hw/gpio/bcm2835_gpio.c:346:
+        sendenabledmap(&s->panel, 0x003FFFFFFFFFFFFC); //Pins 0 & 1 are I2C so disable

ERROR: line over 90 characters
#433: FILE: hw/gpio/bcm2835_gpio.c:347:
+        sendinputmap(&s->panel, 0x0000000000000000); //There are no dedicated input pins I know off

ERROR: do not use C99 // comments
#433: FILE: hw/gpio/bcm2835_gpio.c:347:
+        sendinputmap(&s->panel, 0x0000000000000000); //There are no dedicated input pins I know off

WARNING: line over 80 characters
#434: FILE: hw/gpio/bcm2835_gpio.c:348:
+        sendoutputmap(&s->panel, 0x0000800000000000); //Pin 53 is dedicated output LED

ERROR: do not use C99 // comments
#434: FILE: hw/gpio/bcm2835_gpio.c:348:
+        sendoutputmap(&s->panel, 0x0000800000000000); //Pin 53 is dedicated output LED

WARNING: line over 80 characters
#436: FILE: hw/gpio/bcm2835_gpio.c:350:
+        printf("Couldn't connect to a GPIO panel\n"); //John Bradley dummy GPIO Panel

ERROR: do not use C99 // comments
#436: FILE: hw/gpio/bcm2835_gpio.c:350:
+        printf("Couldn't connect to a GPIO panel\n"); //John Bradley dummy GPIO Panel

ERROR: space prohibited after that '&' (ctx:WxW)
#466: FILE: hw/gpio/bcm2835_gpio.c:381:
+    dc->vmsd = & vmstate_bcm2835_gpio;
                ^

ERROR: space prohibited after that '&' (ctx:WxW)
#467: FILE: hw/gpio/bcm2835_gpio.c:382:
+    dc->realize = & bcm2835_gpio_realize;
                   ^

ERROR: space prohibited after that '&' (ctx:WxW)
#468: FILE: hw/gpio/bcm2835_gpio.c:383:
+    dc->reset = & bcm2835_gpio_reset;
                 ^

WARNING: line over 80 characters
#479: FILE: hw/gpio/bcm2835_gpio.c:389:
+                                           .instance_size = sizeof (BCM2835GpioState),

ERROR: space prohibited between function name and open parenthesis '('
#479: FILE: hw/gpio/bcm2835_gpio.c:389:
+                                           .instance_size = sizeof (BCM2835GpioState),

WARNING: line over 80 characters
#481: FILE: hw/gpio/bcm2835_gpio.c:391:
+                                           .class_init = bcm2835_gpio_class_init,

WARNING: architecture specific defines should be avoided
#530: FILE: include/qemu/PanelEmu.h:17:
+#ifdef __cplusplus

ERROR: do not use C99 // comments
#539: FILE: include/qemu/PanelEmu.h:26:
+#define DEFAULT_PORT 0xb1ff       //45567

ERROR: code indent should never use tabs
#547: FILE: include/qemu/PanelEmu.h:34:
+^I                       unless something changed */$

ERROR: do not use C99 // comments
#548: FILE: include/qemu/PanelEmu.h:35:
+        int ProtocolInUse;  //What version of the protocol are we using.

ERROR: "foo* bar" should be "foo *bar"
#551: FILE: include/qemu/PanelEmu.h:38:
+    bool panel_open(panel_connection_t* h);

ERROR: "foo* bar" should be "foo *bar"
#553: FILE: include/qemu/PanelEmu.h:40:
+    bool panel_read(panel_connection_t* h, uint64_t *pinS);

ERROR: "foo* bar" should be "foo *bar"
#554: FILE: include/qemu/PanelEmu.h:41:
+    void senddatatopanel(panel_connection_t* h, uint64_t pinS, bool Value);

ERROR: "foo* bar" should be "foo *bar"
#555: FILE: include/qemu/PanelEmu.h:42:
+    void panel_send_read_command(panel_connection_t* h);

ERROR: "foo* bar" should be "foo *bar"
#556: FILE: include/qemu/PanelEmu.h:43:
+    void sendpincount(panel_connection_t* h, int Num);

ERROR: "foo* bar" should be "foo *bar"
#557: FILE: include/qemu/PanelEmu.h:44:
+    void sendenabledmap(panel_connection_t* h, uint64_t pins);

ERROR: "foo* bar" should be "foo *bar"
#558: FILE: include/qemu/PanelEmu.h:45:
+    void sendinputmap(panel_connection_t* h, uint64_t pins);

ERROR: "foo* bar" should be "foo *bar"
#559: FILE: include/qemu/PanelEmu.h:46:
+    void sendoutputmap(panel_connection_t* h, uint64_t pins);

WARNING: architecture specific defines should be avoided
#562: FILE: include/qemu/PanelEmu.h:49:
+#ifdef __cplusplus

WARNING: architecture specific defines should be avoided
#596: FILE: util/PanelEmu.c:13:
+#ifdef __MINGW32__

ERROR: open brace '{' following enum go on the same line
#608: FILE: util/PanelEmu.c:25:
+typedef enum
+{

ERROR: do not use C99 // comments
#625: FILE: util/PanelEmu.c:42:
+#define PACKETLEN   0  //Includes Packet Length

ERROR: open brace '{' following struct go on the same line
#629: FILE: util/PanelEmu.c:46:
+typedef struct
+{

ERROR: "foo* bar" should be "foo *bar"
#635: FILE: util/PanelEmu.c:52:
+static void panel_send_protocol_command(panel_connection_t* h)

ERROR: "foo* bar" should be "foo *bar"
#647: FILE: util/PanelEmu.c:64:
+void panel_send_read_command(panel_connection_t* h)

ERROR: "foo* bar" should be "foo *bar"
#658: FILE: util/PanelEmu.c:75:
+void senddatatopanel(panel_connection_t* h, uint64_t pin, bool val)

ERROR: spaces required around that '-' (ctx:VxV)
#662: FILE: util/PanelEmu.c:79:
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[6 + 1]-(char *) &Pkt.Data[0];
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#665: FILE: util/PanelEmu.c:82:
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#667: FILE: util/PanelEmu.c:84:
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
                                                    ^

ERROR: "foo* bar" should be "foo *bar"
#673: FILE: util/PanelEmu.c:90:
+void sendpincount(panel_connection_t* h, int val)

ERROR: spaces required around that '-' (ctx:VxV)
#677: FILE: util/PanelEmu.c:94:
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[2 + 1]-(char *) &Pkt.Data[0];
                                                    ^

ERROR: "foo* bar" should be "foo *bar"
#684: FILE: util/PanelEmu.c:101:
+void sendenabledmap(panel_connection_t* h, uint64_t pin)

ERROR: spaces required around that '-' (ctx:VxV)
#688: FILE: util/PanelEmu.c:105:
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[5 + 1]-(char *) &Pkt.Data[0];
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#691: FILE: util/PanelEmu.c:108:
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#693: FILE: util/PanelEmu.c:110:
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
                                                    ^

ERROR: "foo* bar" should be "foo *bar"
#698: FILE: util/PanelEmu.c:115:
+void sendinputmap(panel_connection_t* h, uint64_t pin)

ERROR: spaces required around that '-' (ctx:VxV)
#702: FILE: util/PanelEmu.c:119:
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[5 + 1]-(char *) &Pkt.Data[0];
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#705: FILE: util/PanelEmu.c:122:
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#707: FILE: util/PanelEmu.c:124:
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
                                                    ^

ERROR: "foo* bar" should be "foo *bar"
#712: FILE: util/PanelEmu.c:129:
+void sendoutputmap(panel_connection_t* h, uint64_t pin)

ERROR: spaces required around that '-' (ctx:VxV)
#716: FILE: util/PanelEmu.c:133:
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[5 + 1]-(char *) &Pkt.Data[0];
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#719: FILE: util/PanelEmu.c:136:
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
                                                    ^

ERROR: spaces required around that '&' (ctx:VxV)
#721: FILE: util/PanelEmu.c:138:
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
                                                    ^

ERROR: space prohibited after that '-' (ctx:WxW)
#728: FILE: util/PanelEmu.c:145:
+    if (send(h->socket, (char *) Pkt, Pkt->Data[PACKETLEN], 0) == - 1) {
                                                                   ^

WARNING: architecture specific defines should be avoided
#730: FILE: util/PanelEmu.c:147:
+#ifdef __MINGW32__

ERROR: space prohibited after that '-' (ctx:WxW)
#735: FILE: util/PanelEmu.c:152:
+        h->socket = - 1; /* act like we never connected */
                     ^

ERROR: "foo* bar" should be "foo *bar"
#740: FILE: util/PanelEmu.c:157:
+bool panel_read(panel_connection_t* h, uint64_t* Data)

ERROR: space prohibited between function name and open parenthesis '('
#746: FILE: util/PanelEmu.c:163:
+    CommandPacket *PktPtr = (CommandPacket *) malloc(sizeof (CommandPacket));

ERROR: space prohibited after that '-' (ctx:WxW)
#758: FILE: util/PanelEmu.c:175:
+    if (h->socket != - 1) {
                      ^

ERROR: do not use C99 // comments
#762: FILE: util/PanelEmu.c:179:
+//      printf(PANEL_NAME "panel_read\n");

ERROR: spaces required around that '&&' (ctx:VxO)
#765: FILE: util/PanelEmu.c:182:
+        while (NoError&&! NoData) {
                       ^

ERROR: space prohibited after that '!' (ctx:OxW)
#765: FILE: util/PanelEmu.c:182:
+        while (NoError&&! NoData) {
                         ^

ERROR: line over 90 characters
#770: FILE: util/PanelEmu.c:187:
+                    if ((LengthInBuffer = recv(h->socket, (char *) &Pkt[ReadStart], sizeof (*Pkt) - ReadStart, 0)) > 0) {

ERROR: space prohibited between function name and open parenthesis '('
#770: FILE: util/PanelEmu.c:187:
+                    if ((LengthInBuffer = recv(h->socket, (char *) &Pkt[ReadStart], sizeof (*Pkt) - ReadStart, 0)) > 0) {

ERROR: do not use assignment in if condition
#770: FILE: util/PanelEmu.c:187:
+                    if ((LengthInBuffer = recv(h->socket, (char *) &Pkt[ReadStart], sizeof (*Pkt) - ReadStart, 0)) > 0) {

ERROR: space prohibited before that '++' (ctx:WxB)
#772: FILE: util/PanelEmu.c:189:
+                        for (int i = 0; LengthInBuffer > 0; i ++) {
                                                               ^

ERROR: that open brace { should be on the previous line
#774: FILE: util/PanelEmu.c:191:
+                                switch (Pkt->Data[i + PACKETTYPE])
+                                {

WARNING: line over 80 characters
#778: FILE: util/PanelEmu.c:195:
+                                        *Data |= ((uint64_t) Pkt->Data[i + 3]) << 16;

WARNING: line over 80 characters
#779: FILE: util/PanelEmu.c:196:
+                                        *Data |= ((uint64_t) Pkt->Data[i + 4]) << 32;

WARNING: line over 80 characters
#780: FILE: util/PanelEmu.c:197:
+                                        *Data |= ((uint64_t) Pkt->Data[i + 5]) << 48;

WARNING: line over 80 characters
#786: FILE: util/PanelEmu.c:203:
+                                        h->ProtocolInUse = (int) Pkt->Data[i + 2];

ERROR: that open brace { should be on the previous line
#787: FILE: util/PanelEmu.c:204:
+                                        if(h->ProtocolInUse!=-1)
+                                        {

ERROR: spaces required around that '!=' (ctx:VxO)
#787: FILE: util/PanelEmu.c:204:
+                                        if(h->ProtocolInUse!=-1)
                                                            ^

ERROR: space required before that '-' (ctx:OxV)
#787: FILE: util/PanelEmu.c:204:
+                                        if(h->ProtocolInUse!=-1)
                                                              ^

ERROR: space required before the open parenthesis '('
#787: FILE: util/PanelEmu.c:204:
+                                        if(h->ProtocolInUse!=-1)

ERROR: line over 90 characters
#789: FILE: util/PanelEmu.c:206:
+                                            printf(PANEL_NAME "Protocol %d in used\n",h->ProtocolInUse);

ERROR: space required after that ',' (ctx:VxV)
#789: FILE: util/PanelEmu.c:206:
+                                            printf(PANEL_NAME "Protocol %d in used\n",h->ProtocolInUse);
                                                                                      ^

ERROR: that open brace { should be on the previous line
#791: FILE: util/PanelEmu.c:208:
+                                        else
+                                        {

ERROR: else should follow close brace '}'
#791: FILE: util/PanelEmu.c:208:
+                                        }
+                                        else

ERROR: trailing whitespace
#793: FILE: util/PanelEmu.c:210:
+                                            printf(PANEL_NAME "No Common Protocol\n");                                            $

ERROR: line over 90 characters
#793: FILE: util/PanelEmu.c:210:
+                                            printf(PANEL_NAME "No Common Protocol\n");                                            

WARNING: line over 80 characters
#798: FILE: util/PanelEmu.c:215:
+                                        printf(PANEL_NAME "Invalid data received\n");

ERROR: line over 90 characters
#802: FILE: util/PanelEmu.c:219:
+                                i += Pkt->Data[PACKETLEN]; //								Pkt=(CommandPacket *)&(Pkt->Data[Pkt->Data[PACKETLEN]]);

ERROR: code indent should never use tabs
#802: FILE: util/PanelEmu.c:219:
+                                i += Pkt->Data[PACKETLEN]; //^I^I^I^I^I^I^I^IPkt=(CommandPacket *)&(Pkt->Data[Pkt->Data[PACKETLEN]]);$

ERROR: do not use C99 // comments
#802: FILE: util/PanelEmu.c:219:
+                                i += Pkt->Data[PACKETLEN]; //								Pkt=(CommandPacket *)&(Pkt->Data[Pkt->Data[PACKETLEN]]);

ERROR: space prohibited before that '++' (ctx:WxB)
#805: FILE: util/PanelEmu.c:222:
+                                for (int j = 0; j < LengthInBuffer; j ++) {
                                                                       ^

WARNING: architecture specific defines should be avoided
#826: FILE: util/PanelEmu.c:243:
+#ifdef __MINGW32__

ERROR: space prohibited after that '-' (ctx:WxW)
#831: FILE: util/PanelEmu.c:248:
+                h->socket = - 1; /* act like we never connected */
                             ^

ERROR: "foo* bar" should be "foo *bar"
#843: FILE: util/PanelEmu.c:260:
+bool panel_open(panel_connection_t* h)

ERROR: trailing whitespace
#846: FILE: util/PanelEmu.c:263:
+#ifdef __MINGW32__    $

WARNING: architecture specific defines should be avoided
#846: FILE: util/PanelEmu.c:263:
+#ifdef __MINGW32__    

ERROR: trailing whitespace
#849: FILE: util/PanelEmu.c:266:
+    struct sockaddr_in remote;    $

ERROR: trailing whitespace
#851: FILE: util/PanelEmu.c:268:
+    $

ERROR: trailing whitespace
#854: FILE: util/PanelEmu.c:271:
+#ifdef __MINGW32__    $

WARNING: architecture specific defines should be avoided
#854: FILE: util/PanelEmu.c:271:
+#ifdef __MINGW32__    

ERROR: trailing whitespace
#857: FILE: util/PanelEmu.c:274:
+    printf("NOT __MINGW32__\n");   $

ERROR: trailing whitespace
#858: FILE: util/PanelEmu.c:275:
+#endif    $

ERROR: trailing whitespace
#859: FILE: util/PanelEmu.c:276:
+    $

ERROR: spaces required around that '=' (ctx:VxO)
#860: FILE: util/PanelEmu.c:277:
+    h->socket=-1;
              ^

ERROR: space required before that '-' (ctx:OxV)
#860: FILE: util/PanelEmu.c:277:
+    h->socket=-1;
               ^

ERROR: spaces required around that '=' (ctx:VxO)
#861: FILE: util/PanelEmu.c:278:
+    h->ProtocolInUse=-1;
                     ^

ERROR: space required before that '-' (ctx:OxV)
#861: FILE: util/PanelEmu.c:278:
+    h->ProtocolInUse=-1;
                      ^

ERROR: trailing whitespace
#862: FILE: util/PanelEmu.c:279:
+    $

WARNING: architecture specific defines should be avoided
#863: FILE: util/PanelEmu.c:280:
+#ifdef __MINGW32__

ERROR: braces {} are necessary for all arms of this statement
#865: FILE: util/PanelEmu.c:282:
+    if (WSAStartup(MAKEWORD(1, 1), &wsadata) == SOCKET_ERROR) {
[...]
+    else
[...]

ERROR: else should follow close brace '}'
#868: FILE: util/PanelEmu.c:285:
+    }
+    else

ERROR: space prohibited after that '-' (ctx:WxW)
#871: FILE: util/PanelEmu.c:288:
+        if ((h->socket = socket(AF_INET, SOCK_STREAM, 0)) != - 1) {
                                                              ^

ERROR: do not use assignment in if condition
#871: FILE: util/PanelEmu.c:288:
+        if ((h->socket = socket(AF_INET, SOCK_STREAM, 0)) != - 1) {

WARNING: architecture specific defines should be avoided
#872: FILE: util/PanelEmu.c:289:
+#ifdef __MINGW32__

ERROR: trailing whitespace
#876: FILE: util/PanelEmu.c:293:
+            remote.sin_addr.s_addr = inet_addr("127.0.0.1");            $

ERROR: use memset() instead of bzero()
#878: FILE: util/PanelEmu.c:295:
+            bzero((char *)&remote, sizeof(remote));

ERROR: line over 90 characters
#883: FILE: util/PanelEmu.c:300:
+            if ((rv=connect(h->socket, (struct sockaddr *) &remote, sizeof (remote))) != - 1) {

ERROR: space prohibited between function name and open parenthesis '('
#883: FILE: util/PanelEmu.c:300:
+            if ((rv=connect(h->socket, (struct sockaddr *) &remote, sizeof (remote))) != - 1) {

ERROR: spaces required around that '=' (ctx:VxV)
#883: FILE: util/PanelEmu.c:300:
+            if ((rv=connect(h->socket, (struct sockaddr *) &remote, sizeof (remote))) != - 1) {
                    ^

ERROR: space prohibited after that '-' (ctx:WxW)
#883: FILE: util/PanelEmu.c:300:
+            if ((rv=connect(h->socket, (struct sockaddr *) &remote, sizeof (remote))) != - 1) {
                                                                                          ^

ERROR: do not use assignment in if condition
#883: FILE: util/PanelEmu.c:300:
+            if ((rv=connect(h->socket, (struct sockaddr *) &remote, sizeof (remote))) != - 1) {

WARNING: architecture specific defines should be avoided
#884: FILE: util/PanelEmu.c:301:
+#ifdef __MINGW32__

WARNING: line over 80 characters
#886: FILE: util/PanelEmu.c:303:
+                setsockopt(h->socket, IPPROTO_TCP, TCP_NODELAY, &value, sizeof ( value));

ERROR: space prohibited between function name and open parenthesis '('
#886: FILE: util/PanelEmu.c:303:
+                setsockopt(h->socket, IPPROTO_TCP, TCP_NODELAY, &value, sizeof ( value));

ERROR: space prohibited after that open parenthesis '('
#886: FILE: util/PanelEmu.c:303:
+                setsockopt(h->socket, IPPROTO_TCP, TCP_NODELAY, &value, sizeof ( value));

ERROR: space required after that ',' (ctx:VxV)
#894: FILE: util/PanelEmu.c:311:
+                printf(PANEL_NAME "Connected OK %d\n",rv);
                                                      ^

ERROR: trailing whitespace
#897: FILE: util/PanelEmu.c:314:
+                $

ERROR: spaces required around that '=' (ctx:VxV)
#898: FILE: util/PanelEmu.c:315:
+                returnval=true;
                          ^

ERROR: space required after that ',' (ctx:VxV)
#900: FILE: util/PanelEmu.c:317:
+                printf(PANEL_NAME "connection Failes %d\n",rv);
                                                           ^

WARNING: architecture specific defines should be avoided
#901: FILE: util/PanelEmu.c:318:
+#ifdef __MINGW32__

ERROR: space prohibited after that '-' (ctx:WxW)
#906: FILE: util/PanelEmu.c:323:
+                h->socket = - 1;
                             ^

total: 125 errors, 28 warnings, 857 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

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

* Re: [Qemu-devel] (no subject)
  2017-05-17 22:42 John Bradley
@ 2017-05-18  5:29 ` no-reply
  2017-05-18  5:31 ` no-reply
  1 sibling, 0 replies; 133+ messages in thread
From: no-reply @ 2017-05-18  5:29 UTC (permalink / raw)
  To: flytart; +Cc: famz, qemu-devel, flypie, peter.maydell, qemu-arm

Hi,

This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Subject: [Qemu-devel] (no subject)
Type: series
Message-id: 536fb79a-5753-4143-a5a6-7a189ef5137e@ONE.local

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-mingw@fedora
time make docker-test-build@min-glib
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/536fb79a-5753-4143-a5a6-7a189ef5137e@ONE.local -> patchew/536fb79a-5753-4143-a5a6-7a189ef5137e@ONE.local
Switched to a new branch 'test'
32d5d78 (no subject)

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-1zdsj2xe/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-1zdsj2xe/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPY    RUNNER
    RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache     tar git make gcc g++     zlib-devel glib2-devel SDL-devel pixman-devel     epel-release
HOSTNAME=d9b60ec0a426
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix    /var/tmp/qemu-build/install
BIOS directory    /var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /tmp/qemu-test/src
C compiler        cc
Host C compiler   cc
C++ compiler      
Objective-C compiler cc
ARFLAGS           rv
CFLAGS            -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS       -I/usr/include/pixman-1   -I$(SRC_PATH)/dtc/libfdt -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all
LDFLAGS           -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make              make
install           install
python            python -B
smbd              /usr/sbin/smbd
module support    no
host CPU          x86_64
host big endian   no
target list       x86_64-softmmu aarch64-softmmu
tcg debug enabled no
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
pixman            system
SDL support       yes (1.2.14)
GTK support       no 
GTK GL support    no
VTE support       no 
TLS priority      NORMAL
GNUTLS support    no
GNUTLS rnd        no
libgcrypt         no
libgcrypt kdf     no
nettle            no 
nettle kdf        no
libtasn1          no
curses support    no
virgl support     no
curl support      no
mingw32 support   no
Audio drivers     oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS support    no
VNC support       yes
VNC SASL support  no
VNC JPEG support  no
VNC PNG support   no
xen support       no
brlapi support    no
bluez  support    no
Documentation     no
PIE               yes
vde support       no
netmap support    no
Linux AIO support no
ATTR/XATTR support yes
Install blobs     yes
KVM support       yes
HAX support       no
RDMA support      no
TCG interpreter   no
fdt support       yes
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
Trace backends    log
spice support     no 
rbd support       no
xfsctl support    no
smartcard support no
libusb            no
usb net redir     no
OpenGL support    no
OpenGL dmabufs    no
libiscsi support  no
libnfs support    no
build guest agent yes
QGA VSS support   no
QGA w32 disk info no
QGA MSI support   no
seccomp support   no
coroutine backend ucontext
coroutine pool    yes
debug stack usage no
GlusterFS support no
gcov              gcov
gcov enabled      no
TPM support       yes
libssh2 support   no
TPM passthrough   yes
QOM debugging     yes
lzo support       no
snappy support    no
bzip2 support     no
NUMA host support no
tcmalloc support  no
jemalloc support  no
avx2 optimization no
replication support yes
VxHS block device no
mkdir -p dtc/libfdt
mkdir -p dtc/tests
  GEN     aarch64-softmmu/config-devices.mak.tmp
  GEN     x86_64-softmmu/config-devices.mak.tmp
  GEN     qemu-options.def
  GEN     config-host.h
  GEN     qapi-visit.h
  GEN     qmp-commands.h
  GEN     qapi-types.h
  GEN     qapi-event.h
  GEN     x86_64-softmmu/config-devices.mak
  GEN     qmp-marshal.c
  GEN     aarch64-softmmu/config-devices.mak
  GEN     qapi-types.c
  GEN     qapi-visit.c
  GEN     qapi-event.c
  GEN     qmp-introspect.h
  GEN     qmp-introspect.c
  GEN     trace/generated-tcg-tracers.h
  GEN     trace/generated-helpers-wrappers.h
  GEN     trace/generated-helpers.h
  GEN     trace/generated-helpers.c
  GEN     module_block.h
  GEN     tests/test-qapi-types.h
  GEN     tests/test-qapi-visit.h
  GEN     tests/test-qapi-event.h
  GEN     tests/test-qmp-commands.h
  GEN     tests/test-qmp-introspect.h
  GEN     trace-root.h
  GEN     util/trace.h
  GEN     crypto/trace.h
  GEN     io/trace.h
  GEN     migration/trace.h
  GEN     block/trace.h
  GEN     backends/trace.h
  GEN     hw/block/trace.h
  GEN     hw/block/dataplane/trace.h
  GEN     hw/char/trace.h
  GEN     hw/intc/trace.h
  GEN     hw/net/trace.h
  GEN     hw/virtio/trace.h
  GEN     hw/audio/trace.h
  GEN     hw/misc/trace.h
  GEN     hw/usb/trace.h
  GEN     hw/scsi/trace.h
  GEN     hw/nvram/trace.h
  GEN     hw/display/trace.h
  GEN     hw/input/trace.h
  GEN     hw/timer/trace.h
  GEN     hw/dma/trace.h
  GEN     hw/sparc/trace.h
  GEN     hw/sd/trace.h
  GEN     hw/isa/trace.h
  GEN     hw/mem/trace.h
  GEN     hw/i386/trace.h
  GEN     hw/i386/xen/trace.h
  GEN     hw/9pfs/trace.h
  GEN     hw/ppc/trace.h
  GEN     hw/pci/trace.h
  GEN     hw/s390x/trace.h
  GEN     hw/vfio/trace.h
  GEN     hw/acpi/trace.h
  GEN     hw/arm/trace.h
  GEN     hw/alpha/trace.h
  GEN     hw/xen/trace.h
  GEN     ui/trace.h
  GEN     audio/trace.h
  GEN     net/trace.h
  GEN     target/arm/trace.h
  GEN     target/i386/trace.h
  GEN     target/mips/trace.h
  GEN     target/sparc/trace.h
  GEN     target/s390x/trace.h
  GEN     target/ppc/trace.h
  GEN     qom/trace.h
  GEN     linux-user/trace.h
  GEN     qapi/trace.h
  GEN     trace-root.c
  GEN     util/trace.c
  GEN     crypto/trace.c
  GEN     io/trace.c
  GEN     migration/trace.c
  GEN     block/trace.c
  GEN     backends/trace.c
  GEN     hw/block/trace.c
  GEN     hw/block/dataplane/trace.c
  GEN     hw/char/trace.c
  GEN     hw/intc/trace.c
  GEN     hw/net/trace.c
  GEN     hw/virtio/trace.c
  GEN     hw/audio/trace.c
  GEN     hw/misc/trace.c
  GEN     hw/usb/trace.c
  GEN     hw/scsi/trace.c
  GEN     hw/nvram/trace.c
  GEN     hw/display/trace.c
  GEN     hw/input/trace.c
  GEN     hw/timer/trace.c
  GEN     hw/dma/trace.c
  GEN     hw/sparc/trace.c
  GEN     hw/sd/trace.c
  GEN     hw/isa/trace.c
  GEN     hw/mem/trace.c
  GEN     hw/i386/trace.c
  GEN     hw/i386/xen/trace.c
  GEN     hw/9pfs/trace.c
  GEN     hw/ppc/trace.c
  GEN     hw/pci/trace.c
  GEN     hw/s390x/trace.c
  GEN     hw/vfio/trace.c
  GEN     hw/acpi/trace.c
  GEN     hw/arm/trace.c
  GEN     hw/alpha/trace.c
  GEN     hw/xen/trace.c
  GEN     ui/trace.c
  GEN     audio/trace.c
  GEN     net/trace.c
  GEN     target/arm/trace.c
  GEN     target/i386/trace.c
  GEN     target/mips/trace.c
  GEN     target/sparc/trace.c
  GEN     target/s390x/trace.c
  GEN     target/ppc/trace.c
  GEN     qom/trace.c
  GEN     linux-user/trace.c
  GEN     qapi/trace.c
  GEN     config-all-devices.mak
	 DEP /tmp/qemu-test/src/dtc/tests/dumptrees.c
	 DEP /tmp/qemu-test/src/dtc/tests/trees.S
	 DEP /tmp/qemu-test/src/dtc/tests/testutils.c
	 DEP /tmp/qemu-test/src/dtc/tests/value-labels.c
	 DEP /tmp/qemu-test/src/dtc/tests/asm_tree_dump.c
	 DEP /tmp/qemu-test/src/dtc/tests/truncated_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/overlay_bad_fixup.c
	 DEP /tmp/qemu-test/src/dtc/tests/check_path.c
	 DEP /tmp/qemu-test/src/dtc/tests/subnode_iterate.c
	 DEP /tmp/qemu-test/src/dtc/tests/overlay.c
	 DEP /tmp/qemu-test/src/dtc/tests/property_iterate.c
	 DEP /tmp/qemu-test/src/dtc/tests/integer-expressions.c
	 DEP /tmp/qemu-test/src/dtc/tests/utilfdt_test.c
	 DEP /tmp/qemu-test/src/dtc/tests/path_offset_aliases.c
	 DEP /tmp/qemu-test/src/dtc/tests/add_subnode_with_nops.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtb_reverse.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_unordered.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_ordered.c
	 DEP /tmp/qemu-test/src/dtc/tests/extra-terminating-null.c
	 DEP /tmp/qemu-test/src/dtc/tests/incbin.c
	 DEP /tmp/qemu-test/src/dtc/tests/boot-cpuid.c
	 DEP /tmp/qemu-test/src/dtc/tests/phandle_format.c
	 DEP /tmp/qemu-test/src/dtc/tests/path-references.c
	 DEP /tmp/qemu-test/src/dtc/tests/references.c
	 DEP /tmp/qemu-test/src/dtc/tests/string_escapes.c
	 DEP /tmp/qemu-test/src/dtc/tests/propname_escapes.c
	 DEP /tmp/qemu-test/src/dtc/tests/appendprop2.c
	 DEP /tmp/qemu-test/src/dtc/tests/appendprop1.c
	 DEP /tmp/qemu-test/src/dtc/tests/del_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/del_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/set_name.c
	 DEP /tmp/qemu-test/src/dtc/tests/setprop.c
	 DEP /tmp/qemu-test/src/dtc/tests/open_pack.c
	 DEP /tmp/qemu-test/src/dtc/tests/rw_tree1.c
	 DEP /tmp/qemu-test/src/dtc/tests/nopulate.c
	 DEP /tmp/qemu-test/src/dtc/tests/mangle-layout.c
	 DEP /tmp/qemu-test/src/dtc/tests/move_and_save.c
	 DEP /tmp/qemu-test/src/dtc/tests/sw_tree1.c
	 DEP /tmp/qemu-test/src/dtc/tests/nop_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/nop_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/setprop_inplace.c
	 DEP /tmp/qemu-test/src/dtc/tests/stringlist.c
	 DEP /tmp/qemu-test/src/dtc/tests/notfound.c
	 DEP /tmp/qemu-test/src/dtc/tests/addr_size_cells.c
	 DEP /tmp/qemu-test/src/dtc/tests/sized_cells.c
	 DEP /tmp/qemu-test/src/dtc/tests/char_literal.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_alias.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_compatible.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_check_compatible.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_phandle.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_prop_value.c
	 DEP /tmp/qemu-test/src/dtc/tests/parent_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_path.c
	 DEP /tmp/qemu-test/src/dtc/tests/supernode_atdepth_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_phandle.c
	 DEP /tmp/qemu-test/src/dtc/tests/getprop.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_name.c
	 DEP /tmp/qemu-test/src/dtc/tests/path_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/subnode_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/find_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/root_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_mem_rsv.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_overlay.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_empty_tree.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_addresses.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_strerror.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_rw.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_sw.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_wip.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_ro.c
	 DEP /tmp/qemu-test/src/dtc/util.c
	 DEP /tmp/qemu-test/src/dtc/fdtput.c
	 DEP /tmp/qemu-test/src/dtc/fdtget.c
	 DEP /tmp/qemu-test/src/dtc/fdtdump.c
	 DEP /tmp/qemu-test/src/dtc/srcpos.c
	 LEX convert-dtsv0-lexer.lex.c
make[1]: flex: Command not found
	 LEX dtc-lexer.lex.c
make[1]: flex: Command not found
	 BISON dtc-parser.tab.c
	 DEP /tmp/qemu-test/src/dtc/treesource.c
make[1]: bison: Command not found
	 DEP /tmp/qemu-test/src/dtc/livetree.c
	 DEP /tmp/qemu-test/src/dtc/fstree.c
	 DEP /tmp/qemu-test/src/dtc/flattree.c
	 DEP /tmp/qemu-test/src/dtc/dtc.c
	 DEP /tmp/qemu-test/src/dtc/data.c
	 DEP /tmp/qemu-test/src/dtc/checks.c
	CHK version_gen.h
	 BISON dtc-parser.tab.c
	UPD version_gen.h
	 LEX dtc-lexer.lex.c
	 LEX convert-dtsv0-lexer.lex.c
make[1]: bison: Command not found
make[1]: flex: Command not found
make[1]: flex: Command not found
	 DEP /tmp/qemu-test/src/dtc/util.c
	 LEX convert-dtsv0-lexer.lex.c
	 LEX dtc-lexer.lex.c
make[1]: flex: Command not found
make[1]: 	 BISON dtc-parser.tab.c
flex: Command not found
make[1]: bison: Command not found
	 CC libfdt/fdt.o
	 CC libfdt/fdt_ro.o
	 CC libfdt/fdt_rw.o
	 CC libfdt/fdt_sw.o
	 CC libfdt/fdt_strerror.o
	 CC libfdt/fdt_wip.o
	 CC libfdt/fdt_empty_tree.o
	 CC libfdt/fdt_addresses.o
	 CC libfdt/fdt_overlay.o
	 AR libfdt/libfdt.a
ar: creating libfdt/libfdt.a
a - libfdt/fdt.o
a - libfdt/fdt_ro.o
a - libfdt/fdt_wip.o
a - libfdt/fdt_sw.o
a - libfdt/fdt_rw.o
a - libfdt/fdt_strerror.o
a - libfdt/fdt_empty_tree.o
a - libfdt/fdt_addresses.o
a - libfdt/fdt_overlay.o
	 BISON dtc-parser.tab.c
	 LEX dtc-lexer.lex.c
make[1]: bison: Command not found
make[1]: flex: Command not found
	 LEX convert-dtsv0-lexer.lex.c
make[1]: flex: Command not found
  CC      tests/qemu-iotests/socket_scm_helper.o
  GEN     qga/qapi-generated/qga-qapi-types.h
  GEN     qga/qapi-generated/qga-qapi-visit.c
  GEN     qga/qapi-generated/qga-qmp-commands.h
  GEN     qga/qapi-generated/qga-qapi-visit.h
  GEN     qga/qapi-generated/qga-qapi-types.c
  GEN     qga/qapi-generated/qga-qmp-marshal.c
  CC      qmp-introspect.o
  CC      qapi-types.o
  CC      qapi-visit.o
  CC      qapi-event.o
  CC      qapi/qapi-visit-core.o
  CC      qapi/qapi-dealloc-visitor.o
  CC      qapi/qobject-input-visitor.o
  CC      qapi/qobject-output-visitor.o
  CC      qapi/qmp-registry.o
  CC      qapi/qmp-dispatch.o
  CC      qapi/string-input-visitor.o
  CC      qapi/string-output-visitor.o
  CC      qapi/opts-visitor.o
  CC      qapi/qapi-clone-visitor.o
  CC      qapi/qapi-util.o
  CC      qapi/qmp-event.o
  CC      qobject/qnull.o
  CC      qobject/qint.o
  CC      qobject/qstring.o
  CC      qobject/qdict.o
  CC      qobject/qfloat.o
  CC      qobject/qlist.o
  CC      qobject/qbool.o
  CC      qobject/qjson.o
  CC      qobject/qobject.o
  CC      qobject/json-lexer.o
  CC      qobject/json-streamer.o
  CC      qobject/json-parser.o
  CC      trace/control.o
  CC      trace/qmp.o
  CC      util/osdep.o
  CC      util/cutils.o
  CC      util/unicode.o
  CC      util/qemu-timer-common.o
  CC      util/bufferiszero.o
  CC      util/lockcnt.o
  CC      util/aiocb.o
  CC      util/async.o
  CC      util/thread-pool.o
  CC      util/qemu-timer.o
  CC      util/main-loop.o
  CC      util/iohandler.o
  CC      util/aio-posix.o
  CC      util/compatfd.o
  CC      util/event_notifier-posix.o
  CC      util/mmap-alloc.o
  CC      util/oslib-posix.o
  CC      util/qemu-thread-posix.o
  CC      util/qemu-openpty.o
  CC      util/memfd.o
  CC      util/envlist.o
  CC      util/path.o
  CC      util/module.o
  CC      util/host-utils.o
  CC      util/bitmap.o
  CC      util/bitops.o
  CC      util/hbitmap.o
  CC      util/fifo8.o
  CC      util/acl.o
  CC      util/error.o
  CC      util/qemu-error.o
  CC      util/id.o
  CC      util/iov.o
  CC      util/qemu-config.o
  CC      util/qemu-sockets.o
  CC      util/notify.o
  CC      util/uri.o
  CC      util/qemu-option.o
  CC      util/qemu-progress.o
  CC      util/hexdump.o
  CC      util/crc32c.o
  CC      util/keyval.o
  CC      util/uuid.o
  CC      util/throttle.o
  CC      util/getauxval.o
  CC      util/rcu.o
  CC      util/readline.o
  CC      util/qemu-coroutine.o
  CC      util/qemu-coroutine-lock.o
  CC      util/qemu-coroutine-io.o
  CC      util/qemu-coroutine-sleep.o
  CC      util/coroutine-ucontext.o
  CC      util/buffer.o
  CC      util/base64.o
  CC      util/timed-average.o
  CC      util/log.o
  CC      util/qdist.o
  CC      util/qht.o
  CC      util/range.o
  CC      util/systemd.o
  CC      trace-root.o
  CC      util/PanelEmu.o
  CC      crypto/trace.o
  CC      util/trace.o
  CC      io/trace.o
  CC      migration/trace.o
  CC      block/trace.o
  CC      backends/trace.o
  CC      hw/block/trace.o
  CC      hw/block/dataplane/trace.o
  CC      hw/char/trace.o
  CC      hw/intc/trace.o
  CC      hw/net/trace.o
  CC      hw/virtio/trace.o
  CC      hw/audio/trace.o
  CC      hw/misc/trace.o
  CC      hw/usb/trace.o
  CC      hw/display/trace.o
  CC      hw/nvram/trace.o
  CC      hw/scsi/trace.o
  CC      hw/timer/trace.o
  CC      hw/input/trace.o
  CC      hw/dma/trace.o
  CC      hw/sparc/trace.o
  CC      hw/sd/trace.o
  CC      hw/isa/trace.o
  CC      hw/mem/trace.o
  CC      hw/i386/trace.o
  CC      hw/i386/xen/trace.o
  CC      hw/9pfs/trace.o
  CC      hw/ppc/trace.o
  CC      hw/pci/trace.o
  CC      hw/s390x/trace.o
  CC      hw/vfio/trace.o
  CC      hw/arm/trace.o
  CC      hw/acpi/trace.o
  CC      hw/alpha/trace.o
  CC      hw/xen/trace.o
  CC      ui/trace.o
  CC      audio/trace.o
  CC      net/trace.o
  CC      target/arm/trace.o
  CC      target/i386/trace.o
  CC      target/mips/trace.o
  CC      target/sparc/trace.o
  CC      target/s390x/trace.o
  CC      target/ppc/trace.o
/tmp/qemu-test/src/util/PanelEmu.c: In function ‘panel_read’:
/tmp/qemu-test/src/util/PanelEmu.c:189: error: ‘for’ loop initial declarations are only allowed in C99 mode
/tmp/qemu-test/src/util/PanelEmu.c:189: note: use option -std=c99 or -std=gnu99 to compile your code
/tmp/qemu-test/src/util/PanelEmu.c:222: error: ‘for’ loop initial declarations are only allowed in C99 mode
make: *** [util/PanelEmu.o] Error 1
make: *** Waiting for unfinished jobs....
  CC      qom/trace.o
tests/docker/Makefile.include:118: recipe for target 'docker-run' failed
make[1]: *** [docker-run] Error 2
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-1zdsj2xe/src'
tests/docker/Makefile.include:149: recipe for target 'docker-run-test-quick@centos6' failed
make: *** [docker-run-test-quick@centos6] Error 2
=== OUTPUT END ===

Test command exited with code: 2


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

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

* [Qemu-devel] (no subject)
@ 2017-05-17 22:42 John Bradley
  2017-05-18  5:29 ` no-reply
  2017-05-18  5:31 ` no-reply
  0 siblings, 2 replies; 133+ messages in thread
From: John Bradley @ 2017-05-17 22:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: flypie, eblake

>From 836daaff38940535548043f2e8f2e3df7a62d473 Mon Sep 17 00:00:00 2001
From: John Bradley <flypie@rocketmail.com>
Date: Wed, 17 May 2017 18:57:21 +0100
Subject: [PATCH] [PATCH] Add code to connect with
 https://github.com/flypie/GDummyPanel The code uses GNU Sockets & Windows
 sockets as on MINGW GNU no available. This is inteded as a Demo for RFC.

Signed-off-by: John Bradley <flypie@rocketmail.com>
---
 hw/gpio/bcm2835_gpio.c         | 330 +++++++++++++++++++++++------------------
 include/hw/gpio/bcm2835_gpio.h |   5 +
 include/qemu/PanelEmu.h        |  54 +++++++
 util/Makefile.objs             |   1 +
 util/PanelEmu.c                | 329 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 577 insertions(+), 142 deletions(-)
 create mode 100644 include/qemu/PanelEmu.h
 create mode 100644 util/PanelEmu.c

diff --git a/hw/gpio/bcm2835_gpio.c b/hw/gpio/bcm2835_gpio.c
index acc2e3cf9e..14bd059861 100644
--- a/hw/gpio/bcm2835_gpio.c
+++ b/hw/gpio/bcm2835_gpio.c
@@ -19,6 +19,8 @@
 #include "hw/sd/sd.h"
 #include "hw/gpio/bcm2835_gpio.h"
 
+
+
 #define GPFSEL0   0x00
 #define GPFSEL1   0x04
 #define GPFSEL2   0x08
@@ -53,9 +55,9 @@ static uint32_t gpfsel_get(BCM2835GpioState *s, uint8_t reg)
 {
     int i;
     uint32_t value = 0;
-    for (i = 0; i < 10; i++) {
+    for (i = 0; i < 10; i ++) {
         uint32_t index = 10 * reg + i;
-        if (index < sizeof(s->fsel)) {
+        if (index < sizeof (s->fsel)) {
             value |= (s->fsel[index] & 0x7) << (3 * i);
         }
     }
@@ -65,9 +67,9 @@ static uint32_t gpfsel_get(BCM2835GpioState *s, uint8_t reg)
 static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, uint32_t value)
 {
     int i;
-    for (i = 0; i < 10; i++) {
+    for (i = 0; i < 10; i ++) {
         uint32_t index = 10 * reg + i;
-        if (index < sizeof(s->fsel)) {
+        if (index < sizeof (s->fsel)) {
             int fsel = (value >> (3 * i)) & 0x7;
             s->fsel[index] = fsel;
         }
@@ -75,24 +77,24 @@ static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, uint32_t value)
 
     /* SD controller selection (48-53) */
     if (s->sd_fsel != 0
-            && (s->fsel[48] == 0) /* SD_CLK_R */
-            && (s->fsel[49] == 0) /* SD_CMD_R */
-            && (s->fsel[50] == 0) /* SD_DATA0_R */
-            && (s->fsel[51] == 0) /* SD_DATA1_R */
-            && (s->fsel[52] == 0) /* SD_DATA2_R */
-            && (s->fsel[53] == 0) /* SD_DATA3_R */
-            ) {
+        && (s->fsel[48] == 0) /* SD_CLK_R */
+        && (s->fsel[49] == 0) /* SD_CMD_R */
+        && (s->fsel[50] == 0) /* SD_DATA0_R */
+        && (s->fsel[51] == 0) /* SD_DATA1_R */
+        && (s->fsel[52] == 0) /* SD_DATA2_R */
+        && (s->fsel[53] == 0) /* SD_DATA3_R */
+        ) {
         /* SDHCI controller selected */
         sdbus_reparent_card(s->sdbus_sdhost, s->sdbus_sdhci);
         s->sd_fsel = 0;
     } else if (s->sd_fsel != 4
-            && (s->fsel[48] == 4) /* SD_CLK_R */
-            && (s->fsel[49] == 4) /* SD_CMD_R */
-            && (s->fsel[50] == 4) /* SD_DATA0_R */
-            && (s->fsel[51] == 4) /* SD_DATA1_R */
-            && (s->fsel[52] == 4) /* SD_DATA2_R */
-            && (s->fsel[53] == 4) /* SD_DATA3_R */
-            ) {
+               && (s->fsel[48] == 4) /* SD_CLK_R */
+               && (s->fsel[49] == 4) /* SD_CMD_R */
+               && (s->fsel[50] == 4) /* SD_DATA0_R */
+               && (s->fsel[51] == 4) /* SD_DATA1_R */
+               && (s->fsel[52] == 4) /* SD_DATA2_R */
+               && (s->fsel[53] == 4) /* SD_DATA3_R */
+               ) {
         /* SDHost controller selected */
         sdbus_reparent_card(s->sdbus_sdhci, s->sdbus_sdhost);
         s->sd_fsel = 4;
@@ -108,13 +110,13 @@ static int gpfsel_is_out(BCM2835GpioState *s, int index)
 }
 
 static void gpset(BCM2835GpioState *s,
-        uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
+                  uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
 {
-    uint32_t changes = val & ~*lev;
+    uint32_t changes = val & ~ *lev;
     uint32_t cur = 1;
 
     int i;
-    for (i = 0; i < count; i++) {
+    for (i = 0; i < count; i ++) {
         if ((changes & cur) && (gpfsel_is_out(s, start + i))) {
             qemu_set_irq(s->out[start + i], 1);
         }
@@ -125,132 +127,165 @@ static void gpset(BCM2835GpioState *s,
 }
 
 static void gpclr(BCM2835GpioState *s,
-        uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
+                  uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
 {
     uint32_t changes = val & *lev;
     uint32_t cur = 1;
 
     int i;
-    for (i = 0; i < count; i++) {
+    for (i = 0; i < count; i ++) {
         if ((changes & cur) && (gpfsel_is_out(s, start + i))) {
             qemu_set_irq(s->out[start + i], 0);
         }
         cur <<= 1;
     }
 
-    *lev &= ~val;
+    *lev &= ~ val;
 }
 
-static uint64_t bcm2835_gpio_read(void *opaque, hwaddr offset,
-        unsigned size)
+static uint64_t bcm2835_gpio_read(void *opaque, hwaddr offset, unsigned size)
 {
-    BCM2835GpioState *s = (BCM2835GpioState *)opaque;
+    BCM2835GpioState *s = (BCM2835GpioState *) opaque;
+
+    uint64_t Data;
 
     switch (offset) {
-    case GPFSEL0:
-    case GPFSEL1:
-    case GPFSEL2:
-    case GPFSEL3:
-    case GPFSEL4:
-    case GPFSEL5:
-        return gpfsel_get(s, offset / 4);
-    case GPSET0:
-    case GPSET1:
-        /* Write Only */
-        return 0;
-    case GPCLR0:
-    case GPCLR1:
-        /* Write Only */
-        return 0;
-    case GPLEV0:
-        return s->lev0;
-    case GPLEV1:
-        return s->lev1;
-    case GPEDS0:
-    case GPEDS1:
-    case GPREN0:
-    case GPREN1:
-    case GPFEN0:
-    case GPFEN1:
-    case GPHEN0:
-    case GPHEN1:
-    case GPLEN0:
-    case GPLEN1:
-    case GPAREN0:
-    case GPAREN1:
-    case GPAFEN0:
-    case GPAFEN1:
-    case GPPUD:
-    case GPPUDCLK0:
-    case GPPUDCLK1:
-        /* Not implemented */
-        return 0;
-    default:
-        qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
-                __func__, offset);
-        break;
+        case GPFSEL0:
+        case GPFSEL1:
+        case GPFSEL2:
+        case GPFSEL3:
+        case GPFSEL4:
+        case GPFSEL5:
+            return gpfsel_get(s, offset / 4);
+        case GPSET0:
+        case GPSET1:
+            /* Write Only */
+            return 0;
+        case GPCLR0:
+        case GPCLR1:
+            /* Write Only */
+            return 0;
+        case GPLEV0:
+            if (s->panel.socket != - 1) {
+                if (panel_read(&s->panel, &Data)) {
+                    s->lev0 = (uint32_t) Data;
+                    s->lev1 = (uint32_t) (Data >> 32);
+                }
+            }
+            return s->lev0;
+        case GPLEV1:
+            if (s->panel.socket != - 1) {
+                if (panel_read(&s->panel, &Data)) {
+                    s->lev0 = (uint32_t) Data;
+                    s->lev1 = (uint32_t) (Data >> 32);
+                }
+            }
+            return s->lev1;
+        case GPEDS0:
+        case GPEDS1:
+        case GPREN0:
+        case GPREN1:
+        case GPFEN0:
+        case GPFEN1:
+        case GPHEN0:
+        case GPHEN1:
+        case GPLEN0:
+        case GPLEN1:
+        case GPAREN0:
+        case GPAREN1:
+        case GPAFEN0:
+        case GPAFEN1:
+        case GPPUD:
+        case GPPUDCLK0:
+        case GPPUDCLK1:
+            /* Not implemented */
+            return 0;
+        default:
+            qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
+                          __func__, offset);
+            break;
     }
 
     return 0;
 }
 
 static void bcm2835_gpio_write(void *opaque, hwaddr offset,
-        uint64_t value, unsigned size)
+                               uint64_t value, unsigned size)
 {
-    BCM2835GpioState *s = (BCM2835GpioState *)opaque;
+    BCM2835GpioState *s = (BCM2835GpioState *) opaque;
+    uint64_t Data;
+
 
     switch (offset) {
-    case GPFSEL0:
-    case GPFSEL1:
-    case GPFSEL2:
-    case GPFSEL3:
-    case GPFSEL4:
-    case GPFSEL5:
-        gpfsel_set(s, offset / 4, value);
-        break;
-    case GPSET0:
-        gpset(s, value, 0, 32, &s->lev0);
-        break;
-    case GPSET1:
-        gpset(s, value, 32, 22, &s->lev1);
-        break;
-    case GPCLR0:
-        gpclr(s, value, 0, 32, &s->lev0);
-        break;
-    case GPCLR1:
-        gpclr(s, value, 32, 22, &s->lev1);
-        break;
-    case GPLEV0:
-    case GPLEV1:
-        /* Read Only */
-        break;
-    case GPEDS0:
-    case GPEDS1:
-    case GPREN0:
-    case GPREN1:
-    case GPFEN0:
-    case GPFEN1:
-    case GPHEN0:
-    case GPHEN1:
-    case GPLEN0:
-    case GPLEN1:
-    case GPAREN0:
-    case GPAREN1:
-    case GPAFEN0:
-    case GPAFEN1:
-    case GPPUD:
-    case GPPUDCLK0:
-    case GPPUDCLK1:
-        /* Not implemented */
-        break;
-    default:
-        goto err_out;
+        case GPFSEL0:
+        case GPFSEL1:
+        case GPFSEL2:
+        case GPFSEL3:
+        case GPFSEL4:
+        case GPFSEL5:
+            gpfsel_set(s, offset / 4, value);
+            break;
+        case GPSET0:
+            gpset(s, value, 0, 32, &s->lev0);
+            if (s->panel.socket != - 1) {
+                Data = value;
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel
+            }
+            break;
+        case GPSET1:
+            gpset(s, value, 32, 22, &s->lev1);
+            if (s->panel.socket != - 1) {
+                Data = value;
+                Data <<= 32;
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel
+            }
+            break;
+        case GPCLR0:
+            gpclr(s, value, 0, 32, &s->lev0);
+            if (s->panel.socket != - 1) {
+                Data = value;
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel
+            }
+            break;
+        case GPCLR1:
+            gpclr(s, value, 32, 22, &s->lev1);
+            if (s->panel.socket != - 1) {
+                Data = value;
+                Data <<= 32;
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel
+            }
+            break;
+        case GPLEV0:
+        case GPLEV1:
+            /* Read Only */
+            break;
+        case GPEDS0:
+        case GPEDS1:
+        case GPREN0:
+        case GPREN1:
+        case GPFEN0:
+        case GPFEN1:
+        case GPHEN0:
+        case GPHEN1:
+        case GPLEN0:
+        case GPLEN1:
+        case GPAREN0:
+        case GPAREN1:
+        case GPAFEN0:
+        case GPAFEN1:
+        case GPPUD:
+        case GPPUDCLK0:
+        case GPPUDCLK1:
+            /* Not implemented */
+            break;
+        default:
+            goto err_out;
     }
     return;
 
 err_out:
     qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
-            __func__, offset);
+                  __func__, offset);
 }
 
 static void bcm2835_gpio_reset(DeviceState *dev)
@@ -258,7 +293,7 @@ static void bcm2835_gpio_reset(DeviceState *dev)
     BCM2835GpioState *s = BCM2835_GPIO(dev);
 
     int i;
-    for (i = 0; i < 6; i++) {
+    for (i = 0; i < 6; i ++) {
         gpfsel_set(s, i, 0);
     }
 
@@ -272,21 +307,22 @@ static void bcm2835_gpio_reset(DeviceState *dev)
 }
 
 static const MemoryRegionOps bcm2835_gpio_ops = {
-    .read = bcm2835_gpio_read,
-    .write = bcm2835_gpio_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+                                                 .read = bcm2835_gpio_read,
+                                                 .write = bcm2835_gpio_write,
+                                                 .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static const VMStateDescription vmstate_bcm2835_gpio = {
-    .name = "bcm2835_gpio",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_UINT8_ARRAY(fsel, BCM2835GpioState, 54),
-        VMSTATE_UINT32(lev0, BCM2835GpioState),
-        VMSTATE_UINT32(lev1, BCM2835GpioState),
-        VMSTATE_UINT8(sd_fsel, BCM2835GpioState),
-        VMSTATE_END_OF_LIST()
+                                                        .name = "bcm2835_gpio",
+                                                        .version_id = 1,
+                                                        .minimum_version_id = 1,
+                                                        .fields = (VMStateField[])
+    {
+     VMSTATE_UINT8_ARRAY(fsel, BCM2835GpioState, 54),
+     VMSTATE_UINT32(lev0, BCM2835GpioState),
+     VMSTATE_UINT32(lev1, BCM2835GpioState),
+     VMSTATE_UINT8(sd_fsel, BCM2835GpioState),
+     VMSTATE_END_OF_LIST()
     }
 };
 
@@ -296,13 +332,23 @@ static void bcm2835_gpio_init(Object *obj)
     DeviceState *dev = DEVICE(obj);
     SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
 
-    qbus_create_inplace(&s->sdbus, sizeof(s->sdbus),
+    qbus_create_inplace(&s->sdbus, sizeof (s->sdbus),
                         TYPE_SD_BUS, DEVICE(s), "sd-bus");
 
     memory_region_init_io(&s->iomem, obj,
-            &bcm2835_gpio_ops, s, "bcm2835_gpio", 0x1000);
+                          &bcm2835_gpio_ops, s, "bcm2835_gpio", 0x1000);
     sysbus_init_mmio(sbd, &s->iomem);
     qdev_init_gpio_out(dev, s->out, 54);
+
+    /* Get access to the GPIO panel, program will quit on fail */
+    if (panel_open(&s->panel)) {
+        sendpincount(&s->panel, 54); //PI Has 54 Pins
+        sendenabledmap(&s->panel, 0x003FFFFFFFFFFFFC); //Pins 0 & 1 are I2C so disable
+        sendinputmap(&s->panel, 0x0000000000000000); //There are no dedicated input pins I know off
+        sendoutputmap(&s->panel, 0x0000800000000000); //Pin 53 is dedicated output LED
+    } else {
+        printf("Couldn't connect to a GPIO panel\n"); //John Bradley dummy GPIO Panel
+    }
 }
 
 static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
@@ -314,7 +360,7 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
     obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", &err);
     if (obj == NULL) {
         error_setg(errp, "%s: required sdhci link not found: %s",
-                __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(err));
         return;
     }
     s->sdbus_sdhci = SD_BUS(obj);
@@ -322,7 +368,7 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
     obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", &err);
     if (obj == NULL) {
         error_setg(errp, "%s: required sdhost link not found: %s",
-                __func__, error_get_pretty(err));
+                   __func__, error_get_pretty(err));
         return;
     }
     s->sdbus_sdhost = SD_BUS(obj);
@@ -332,17 +378,17 @@ static void bcm2835_gpio_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->vmsd = &vmstate_bcm2835_gpio;
-    dc->realize = &bcm2835_gpio_realize;
-    dc->reset = &bcm2835_gpio_reset;
+    dc->vmsd = & vmstate_bcm2835_gpio;
+    dc->realize = & bcm2835_gpio_realize;
+    dc->reset = & bcm2835_gpio_reset;
 }
 
 static const TypeInfo bcm2835_gpio_info = {
-    .name          = TYPE_BCM2835_GPIO,
-    .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(BCM2835GpioState),
-    .instance_init = bcm2835_gpio_init,
-    .class_init    = bcm2835_gpio_class_init,
+                                           .name = TYPE_BCM2835_GPIO,
+                                           .parent = TYPE_SYS_BUS_DEVICE,
+                                           .instance_size = sizeof (BCM2835GpioState),
+                                           .instance_init = bcm2835_gpio_init,
+                                           .class_init = bcm2835_gpio_class_init,
 };
 
 static void bcm2835_gpio_register_types(void)
diff --git a/include/hw/gpio/bcm2835_gpio.h b/include/hw/gpio/bcm2835_gpio.h
index 9f8e0c720c..73cfda6a6b 100644
--- a/include/hw/gpio/bcm2835_gpio.h
+++ b/include/hw/gpio/bcm2835_gpio.h
@@ -16,6 +16,8 @@
 
 #include "hw/sd/sd.h"
 
+#include "qemu/PanelEmu.h"
+
 typedef struct BCM2835GpioState {
     SysBusDevice parent_obj;
 
@@ -30,6 +32,9 @@ typedef struct BCM2835GpioState {
     uint32_t lev0, lev1;
     uint8_t sd_fsel;
     qemu_irq out[54];
+
+    panel_connection_t panel;
+
 } BCM2835GpioState;
 
 #define TYPE_BCM2835_GPIO "bcm2835_gpio"
diff --git a/include/qemu/PanelEmu.h b/include/qemu/PanelEmu.h
new file mode 100644
index 0000000000..eb9bf053d0
--- /dev/null
+++ b/include/qemu/PanelEmu.h
@@ -0,0 +1,54 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * File:   PanelEmu.h
+ * Author: John Bradley
+ *
+ * Created on 22 April 2017, 22:26
+ */
+
+#ifndef PANELEMU_H
+#define PANELEMU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define DRIVER_NAME "RDC-GPIO: "
+#define PANEL_NAME "GPIO panel: "
+
+
+#define DEFAULT_PORT 0xb1ff       //45567
+
+#define PANEL_PINS 54
+
+    typedef struct panel_connection {
+        int socket; /* socket we'll connect to the panel with */
+        fd_set fds; /* list of descriptors (only the above socket */
+        char last[PANEL_PINS / 8]; /* we don't want to send updates to the panel
+	                       unless something changed */
+        int ProtocolInUse;  //What version of the protocol are we using.
+    } panel_connection_t;
+
+    bool panel_open(panel_connection_t* h);
+
+    bool panel_read(panel_connection_t* h, uint64_t *pinS);
+    void senddatatopanel(panel_connection_t* h, uint64_t pinS, bool Value);
+    void panel_send_read_command(panel_connection_t* h);
+    void sendpincount(panel_connection_t* h, int Num);
+    void sendenabledmap(panel_connection_t* h, uint64_t pins);
+    void sendinputmap(panel_connection_t* h, uint64_t pins);
+    void sendoutputmap(panel_connection_t* h, uint64_t pins);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PANELEMU_H */
+
diff --git a/util/Makefile.objs b/util/Makefile.objs
index c6205ebf86..8316ed79ba 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -43,3 +43,4 @@ util-obj-y += qdist.o
 util-obj-y += qht.o
 util-obj-y += range.o
 util-obj-y += systemd.o
+util-obj-y += PanelEmu.o
\ No newline at end of file
diff --git a/util/PanelEmu.c b/util/PanelEmu.c
new file mode 100644
index 0000000000..d428dd7b53
--- /dev/null
+++ b/util/PanelEmu.c
@@ -0,0 +1,329 @@
+/*
+ * Emulation for Rasp PI GPIO via Server connected to via Socket
+ *
+ */
+#include "qemu/osdep.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#ifdef __MINGW32__
+#include <winsock2.h>
+#else
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+
+#include "qemu/PanelEmu.h"
+
+typedef enum
+{
+    PROTOCOLDESCFROMQEMU = 0,
+    PROTOCOLDESCFROMPANEL = 1,
+    PINSTOPANEL = 2,
+    READREQ = 3,
+    PINCOUNT = 4,
+    ENABLEMAP = 5,
+    INPUTMAP = 6,
+    OUTPUTMAP = 7,
+    PINSTOQEMU = 8
+} PacketType;
+
+#define MINPROTOCOL 0
+#define MAXPROTOCOL 0
+
+#define MAXPACKET   255
+
+#define PACKETLEN   0  //Includes Packet Length
+#define PACKETTYPE  1
+
+typedef struct
+{
+    unsigned short int Data[MAXPACKET];
+} CommandPacket;
+
+static void panel_command(panel_connection_t *h, CommandPacket *Pkt);
+
+static void panel_send_protocol_command(panel_connection_t* h)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = 8;
+    Pkt.Data[PACKETTYPE] = PROTOCOLDESCFROMQEMU;
+    Pkt.Data[2] = MINPROTOCOL;
+    Pkt.Data[3] = MAXPROTOCOL;
+
+    panel_command(h, &Pkt);
+}
+
+void panel_send_read_command(panel_connection_t* h)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = 4;
+    Pkt.Data[PACKETTYPE] = READREQ;
+
+    panel_command(h, &Pkt);
+}
+
+/* Set a pin to a specified value */
+void senddatatopanel(panel_connection_t* h, uint64_t pin, bool val)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[6 + 1]-(char *) &Pkt.Data[0];
+    Pkt.Data[PACKETTYPE] = PINSTOPANEL;
+    Pkt.Data[2] = (unsigned short int) (pin & 0xFFFF);
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
+    Pkt.Data[4] = (unsigned short int) (pin >> 32 & 0xFFFF);
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
+    Pkt.Data[6] = val;
+
+    panel_command(h, &Pkt);
+}
+
+void sendpincount(panel_connection_t* h, int val)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[2 + 1]-(char *) &Pkt.Data[0];
+    Pkt.Data[PACKETTYPE] = PINCOUNT;
+    Pkt.Data[2] = val;
+
+    panel_command(h, &Pkt);
+}
+
+void sendenabledmap(panel_connection_t* h, uint64_t pin)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[5 + 1]-(char *) &Pkt.Data[0];
+    Pkt.Data[PACKETTYPE] = ENABLEMAP;
+    Pkt.Data[2] = (unsigned short int) (pin & 0xFFFF);
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
+    Pkt.Data[4] = (unsigned short int) (pin >> 32 & 0xFFFF);
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
+
+    panel_command(h, &Pkt);
+}
+
+void sendinputmap(panel_connection_t* h, uint64_t pin)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[5 + 1]-(char *) &Pkt.Data[0];
+    Pkt.Data[PACKETTYPE] = INPUTMAP;
+    Pkt.Data[2] = (unsigned short int) (pin & 0xFFFF);
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
+    Pkt.Data[4] = (unsigned short int) (pin >> 32 & 0xFFFF);
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
+
+    panel_command(h, &Pkt);
+}
+
+void sendoutputmap(panel_connection_t* h, uint64_t pin)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[5 + 1]-(char *) &Pkt.Data[0];
+    Pkt.Data[PACKETTYPE] = OUTPUTMAP;
+    Pkt.Data[2] = (unsigned short int) (pin & 0xFFFF);
+    Pkt.Data[3] = (unsigned short int) ((pin >> 16)&0xFFFF);
+    Pkt.Data[4] = (unsigned short int) (pin >> 32 & 0xFFFF);
+    Pkt.Data[5] = (unsigned short int) ((pin >> 48)&0xFFFF);
+
+    panel_command(h, &Pkt);
+}
+
+static void panel_command(panel_connection_t *h, CommandPacket *Pkt)
+{
+    if (send(h->socket, (char *) Pkt, Pkt->Data[PACKETLEN], 0) == - 1) {
+        perror(PANEL_NAME "send");
+#ifdef __MINGW32__
+        closesocket(h->socket);
+#else
+        close(h->socket);
+#endif
+        h->socket = - 1; /* act like we never connected */
+    }
+}
+
+/* Wait for values to be read back from panel */
+bool panel_read(panel_connection_t* h, uint64_t* Data)
+{
+    fd_set rfds, efds;
+    int LengthInBuffer;
+    int select_res = 0;
+
+    CommandPacket *PktPtr = (CommandPacket *) malloc(sizeof (CommandPacket));
+    CommandPacket *Pkt;
+    bool NoError = true;
+    bool NewData = false;
+    bool NoData = false;
+    struct timeval timeout;
+
+    int ReadStart = 0;
+
+    timeout.tv_sec = 0;
+    timeout.tv_usec = 0;
+
+    if (h->socket != - 1) {
+        rfds = h->fds;
+        efds = h->fds;
+
+//      printf(PANEL_NAME "panel_read\n");
+
+        Pkt = PktPtr;
+        while (NoError&&! NoData) {
+            select_res = select(h->socket + 1, &rfds, NULL, &efds, &timeout);
+            if (select_res > 0) {
+                if (FD_ISSET(h->socket, &rfds)) {
+                    /* receive more data */
+                    if ((LengthInBuffer = recv(h->socket, (char *) &Pkt[ReadStart], sizeof (*Pkt) - ReadStart, 0)) > 0) {
+                        LengthInBuffer += ReadStart;
+                        for (int i = 0; LengthInBuffer > 0; i ++) {
+                            if (LengthInBuffer >= Pkt->Data[i + PACKETLEN]) {
+                                switch (Pkt->Data[i + PACKETTYPE])
+                                {
+                                    case PINSTOQEMU:
+                                        *Data = (uint64_t) Pkt->Data[i + 2];
+                                        *Data |= ((uint64_t) Pkt->Data[i + 3]) << 16;
+                                        *Data |= ((uint64_t) Pkt->Data[i + 4]) << 32;
+                                        *Data |= ((uint64_t) Pkt->Data[i + 5]) << 48;
+
+                                        NewData = true;
+                                        break;
+
+                                    case PROTOCOLDESCFROMPANEL:
+                                        h->ProtocolInUse = (int) Pkt->Data[i + 2];
+                                        if(h->ProtocolInUse!=-1)
+                                        {
+                                            printf(PANEL_NAME "Protocol %d in used\n",h->ProtocolInUse);
+                                        }
+                                        else
+                                        {
+                                            printf(PANEL_NAME "No Common Protocol\n");                                            
+                                        }
+                                        break;
+
+                                    default:
+                                        printf(PANEL_NAME "Invalid data received\n");
+                                        break;
+                                }
+                                LengthInBuffer -= Pkt->Data[PACKETLEN];
+                                i += Pkt->Data[PACKETLEN]; //								Pkt=(CommandPacket *)&(Pkt->Data[Pkt->Data[PACKETLEN]]);
+                            } else {
+                                ReadStart = LengthInBuffer;
+                                for (int j = 0; j < LengthInBuffer; j ++) {
+                                    Pkt->Data[j] = Pkt->Data[i + j];
+                                }
+                                printf(PANEL_NAME "Partial Packet Read");
+                            }
+                        }
+                    } else {
+                        if (LengthInBuffer < 0) {
+                            if (errno != EINTR) {
+                                printf(PANEL_NAME "recv");
+                                NoError = FALSE;
+                            }
+                        } else {
+                            printf(PANEL_NAME "closed connection\n");
+                            NoError = FALSE;
+                        }
+                    }
+                }
+            } else if (select_res == 0) {
+                NoData = true;
+            } else if (errno != EINTR) {
+#ifdef __MINGW32__
+                closesocket(h->socket);
+#else
+                close(h->socket);
+#endif
+                h->socket = - 1; /* act like we never connected */
+                perror(PANEL_NAME "select error");
+                NoError = FALSE;
+            }
+        }
+    }
+
+    free(PktPtr);
+
+    return NewData;
+}
+
+bool panel_open(panel_connection_t* h)
+{
+    int rv;
+#ifdef __MINGW32__    
+    struct sockaddr_in remote;
+#else
+    struct sockaddr_in remote;    
+#endif
+    
+    bool returnval = false;
+
+#ifdef __MINGW32__    
+    printf("__MINGW32__\n");
+#else
+    printf("NOT __MINGW32__\n");   
+#endif    
+    
+    h->socket=-1;
+    h->ProtocolInUse=-1;
+    
+#ifdef __MINGW32__
+    WSADATA wsadata;
+    if (WSAStartup(MAKEWORD(1, 1), &wsadata) == SOCKET_ERROR) {
+        printf("Error creating socket.\n");
+    }
+    else
+#endif
+    {
+        if ((h->socket = socket(AF_INET, SOCK_STREAM, 0)) != - 1) {
+#ifdef __MINGW32__
+            memset((char *)&remote, 0, sizeof(remote));
+            remote.sin_family = AF_INET;
+            remote.sin_port = htons(DEFAULT_PORT);
+            remote.sin_addr.s_addr = inet_addr("127.0.0.1");            
+#else
+            bzero((char *)&remote, sizeof(remote));
+            remote.sin_family = AF_INET;
+            remote.sin_port = htons(DEFAULT_PORT);
+            remote.sin_addr.s_addr = inet_addr("127.0.0.1");
+#endif
+            if ((rv=connect(h->socket, (struct sockaddr *) &remote, sizeof (remote))) != - 1) {
+#ifdef __MINGW32__
+                char value = 1;
+                setsockopt(h->socket, IPPROTO_TCP, TCP_NODELAY, &value, sizeof ( value));
+
+#endif
+                FD_ZERO(&h->fds);
+
+                /* Set our connected socket */
+                FD_SET(h->socket, &h->fds);
+
+                printf(PANEL_NAME "Connected OK %d\n",rv);
+
+                panel_send_protocol_command(h);
+                
+                returnval=true;
+            } else {
+                printf(PANEL_NAME "connection Failes %d\n",rv);
+#ifdef __MINGW32__
+                closesocket(h->socket);
+#else
+                close(h->socket);
+#endif
+                h->socket = - 1;
+            }
+        }
+    }
+    return returnval;
+}
+
-- 
2.13.0.windows.1

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

* Re: [Qemu-devel] (no subject)
       [not found] <CAMj-D2DO_CfvD77izsGfggoKP45HSC9aD6auUPAYC9Yeq_aX7w@mail.gmail.com>
@ 2017-05-04 16:44 ` gengdongjiu
  0 siblings, 0 replies; 133+ messages in thread
From: gengdongjiu @ 2017-05-04 16:44 UTC (permalink / raw)
  To: mtsirkin, kvm, Tyler Baicar, qemu-devel, Xiongfeng Wang, ben,
	linux, kvmarm, huangshaoyu, lersek, songwenjun, wuquanming,
	Marc Zyngier, qemu-arm, imammedo, linux-arm-kernel,
	Ard Biesheuvel, pbonzini, James Morse

Dear James,
   Thanks a lot for your review and comments. I am very sorry for the
late response.


2017-05-04 23:42 GMT+08:00 gengdongjiu <gengdj.1984@gmail.com>:
>  Hi Dongjiu Geng,
>
> On 30/04/17 06:37, Dongjiu Geng wrote:
>> when happen SEA, deliver signal bus and handle the ioctl that
>> inject SEA abort to guest, so that guest can handle the SEA error.
>
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 105b6ab..a96594f 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -20,8 +20,10 @@
>> @@ -1238,6 +1240,36 @@ static void coherent_cache_guest_page(struct kvm_vcpu *vcpu, kvm_pfn_t pfn,
>>   __coherent_cache_guest_page(vcpu, pfn, size);
>>  }
>>
>> +static void kvm_send_signal(unsigned long address, bool hugetlb, bool hwpoison)
>> +{
>> + siginfo_t info;
>> +
>> + info.si_signo   = SIGBUS;
>> + info.si_errno   = 0;
>> + if (hwpoison)
>> + info.si_code    = BUS_MCEERR_AR;
>> + else
>> + info.si_code    = 0;
>> +
>> + info.si_addr    = (void __user *)address;
>> + if (hugetlb)
>> + info.si_addr_lsb = PMD_SHIFT;
>> + else
>> + info.si_addr_lsb = PAGE_SHIFT;
>> +
>> + send_sig_info(SIGBUS, &info, current);
>> +}
>> +
> «  [hide part of quote]
>
> Punit reviewed the other version of this patch, this PMD_SHIFT is not the right
> thing to do, it needs a more accurate set of calls and shifts as there may be
> hugetlbfs pages other than PMD_SIZE.
>
> https://www.spinics.net/lists/arm-kernel/msg568919.html
>
> I haven't posted a new version of that patch because I was still hunting a bug
> in the hugepage/hwpoison code, even with Punit's fixes series I see -EFAULT
> returned to userspace instead of this hwpoison code being invoked.

  Ok, got it, thanks for your information.
>
> Please avoid duplicating functionality between patches, it wastes reviewers
> time, especially when we know there are problems with this approach.
>
>
>> +static void kvm_handle_bad_page(unsigned long address,
>> + bool hugetlb, bool hwpoison)
>> +{
>> + /* handle both hwpoison and other synchronous external Abort */
>> + if (hwpoison)
>> + kvm_send_signal(address, hugetlb, true);
>> + else
>> + kvm_send_signal(address, hugetlb, false);
>> +}
>
> Why the extra level of indirection? We only want to signal userspace like this
> from KVM for hwpoison. Signals for RAS related reasons should come from the bits
> of the kernel that decoded the error.

For the SEA, the are maily two types:
0b010000 Synchronous External Abort on memory access.
0b0101xx Synchronous External Abort on page table walk. DFSC[1:0]
encode the level.

hwpoison should belong to the  "Synchronous External Abort on memory access"
if the SEA type is not hwpoison, such as page table walk, do you mean
KVM do not deliver the SIGBUS?
If so, how the KVM handle the SEA type other than hwpoison?

>
> (hwpoison for KVM is a corner case as Qemu's memory effectively has two users,
> Qemu and KVM. This isn't the example of how user-space gets signalled.)
>
>
>> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
>> index b37446a..780e3c4 100644
>> --- a/arch/arm64/kvm/guest.c
>> +++ b/arch/arm64/kvm/guest.c
>> @@ -277,6 +277,13 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
>>   return -EINVAL;
>>  }
>>
>> +int kvm_vcpu_ioctl_sea(struct kvm_vcpu *vcpu)
>> +{
>> + kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
>> +
>> + return 0;
>> +}
>
>> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
>> index bb02909..1d2e2e7 100644
>> --- a/include/uapi/linux/kvm.h
>> +++ b/include/uapi/linux/kvm.h
>> @@ -1306,6 +1306,7 @@ struct kvm_s390_ucas_mapping {
>>  #define KVM_S390_GET_IRQ_STATE  _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
>>  /* Available with KVM_CAP_X86_SMM */
>>  #define KVM_SMI                   _IO(KVMIO,   0xb7)
>> +#define KVM_ARM_SEA               _IO(KVMIO,   0xb8)
>>
>>  #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
>>  #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
>>
>
> Why do we need a userspace API for SEA? It can also be done by using
> KVM_{G,S}ET_ONE_REG to change the vcpu registers. The advantage of doing it this
> way is you can choose which ESR value to use.
>
> Adding a new API call to do something you could do with an old one doesn't look
> right.

James, I considered your suggestion before that use the
KVM_{G,S}ET_ONE_REG to change the vcpu registers. but I found it does
not have difference to use the alread existed KVM API.  so may be
changing the vcpu registers in qemu will duplicate with the KVM APIs.

injection a SEA is no more than setting some registers: elr_el1, PC,
PSTATE, SPSR_el1, far_el1, esr_el1
I seen this KVM API do the same thing as Qemu.  do you found call this
API will have issue and necessary to choose another ESR value?

I pasted the alread existed KVM API code:

static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned
long addr)
{
 unsigned long cpsr = *vcpu_cpsr(vcpu);
 bool is_aarch32 = vcpu_mode_is_32bit(vcpu);
 u32 esr = 0;
 *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu);
 *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync);
 *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64;
 *vcpu_spsr(vcpu) = cpsr;
 vcpu_sys_reg(vcpu, FAR_EL1) = addr;
 /*
  * Build an {i,d}abort, depending on the level and the
  * instruction set. Report an external synchronous abort.
  */
 if (kvm_vcpu_trap_il_is32bit(vcpu))
  esr |= ESR_ELx_IL;
 /*
  * Here, the guest runs in AArch64 mode when in EL1. If we get
  * an AArch32 fault, it means we managed to trap an EL0 fault.
  */
 if (is_aarch32 || (cpsr & PSR_MODE_MASK) == PSR_MODE_EL0t)
  esr |= (ESR_ELx_EC_IABT_LOW << ESR_ELx_EC_SHIFT);
 else
  esr |= (ESR_ELx_EC_IABT_CUR << ESR_ELx_EC_SHIFT);
 if (!is_iabt)
  esr |= ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT;
 vcpu_sys_reg(vcpu, ESR_EL1) = esr | ESR_ELx_FSC_EXTABT;
}

static void inject_abt32(struct kvm_vcpu *vcpu, bool is_pabt,
    unsigned long addr)
{
 u32 vect_offset;
 u32 *far, *fsr;
 bool is_lpae;
 if (is_pabt) {
  vect_offset = 12;
  far = &vcpu_cp15(vcpu, c6_IFAR);
  fsr = &vcpu_cp15(vcpu, c5_IFSR);
 } else { /* !iabt */
  vect_offset = 16;
  far = &vcpu_cp15(vcpu, c6_DFAR);
  fsr = &vcpu_cp15(vcpu, c5_DFSR);
 }
 prepare_fault32(vcpu, COMPAT_PSR_MODE_ABT | COMPAT_PSR_A_BIT, vect_offset);
 *far = addr;
 /* Give the guest an IMPLEMENTATION DEFINED exception */
 is_lpae = (vcpu_cp15(vcpu, c2_TTBCR) >> 31);
 if (is_lpae)
  *fsr = 1 << 9 | 0x34;
 else
  *fsr = 0x14;
}


/**
 * kvm_inject_dabt - inject a data abort into the guest
 * @vcpu: The VCPU to receive the undefined exception
 * @addr: The address to report in the DFAR
 *
 * It is assumed that this code is called from the VCPU thread and that the
 * VCPU therefore is not currently executing guest code.
 */
void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr)
{
 if (!(vcpu->arch.hcr_el2 & HCR_RW))
  inject_abt32(vcpu, false, addr);
 else
  inject_abt64(vcpu, false, addr);
}


>
>
> Thanks,
>
> James

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

* Re: [Qemu-devel] (no subject)
  2017-03-16 14:50 ` [Qemu-devel] (no subject) Vinzenz 'evilissimo' Feenstra
@ 2017-03-23 13:44   ` Eric Blake
  0 siblings, 0 replies; 133+ messages in thread
From: Eric Blake @ 2017-03-23 13:44 UTC (permalink / raw)
  To: Vinzenz 'evilissimo' Feenstra, qemu-devel; +Cc: mdroth

[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]

On 03/16/2017 09:50 AM, Vinzenz 'evilissimo' Feenstra wrote:
> In this version:

When sending a v2, it's best to send it as a new top-level thread
instead of burying it in-reply-to an older thread. Also, don't forget
the subject line on the header message.

> 
> - Changed the use of strdup to g_strdup and the use of sprintf with a local
>   buffer to use g_strdup_printf instead.
> - Made the majority of fields in the GuestOSInfo optional to allow 0 values
> - Used the right target version in the schema (2.10 vs 2.8 before)
> - Refactored the code for deciding which release/version file to use to use a
>   configuration struct and a while loop to iterate over the options.
> 
> I was looking into the usage of uname, as suggested by eric, however after
> looking into this I realized that there's no additional information to be
> gained from this. Therefore I decided that this is still a feasible approach.
> In most cases the code will break out of the loop after accessing the second
> file. For older systems there are some supported fallbacks available, but
> /etc/os-release and /usr/lib/os-release are already quite established.
> 
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* [Qemu-devel] (no subject)
  2017-03-21 14:03 [Qemu-devel] [PATCH] qemu-ga: add guest-get-osinfo command Vinzenz Feenstra
@ 2017-03-16 14:50 ` Vinzenz 'evilissimo' Feenstra
  2017-03-23 13:44   ` Eric Blake
  0 siblings, 1 reply; 133+ messages in thread
From: Vinzenz 'evilissimo' Feenstra @ 2017-03-16 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, eblake

In this version:

- Changed the use of strdup to g_strdup and the use of sprintf with a local
  buffer to use g_strdup_printf instead.
- Made the majority of fields in the GuestOSInfo optional to allow 0 values
- Used the right target version in the schema (2.10 vs 2.8 before)
- Refactored the code for deciding which release/version file to use to use a
  configuration struct and a while loop to iterate over the options.

I was looking into the usage of uname, as suggested by eric, however after
looking into this I realized that there's no additional information to be
gained from this. Therefore I decided that this is still a feasible approach.
In most cases the code will break out of the loop after accessing the second
file. For older systems there are some supported fallbacks available, but
/etc/os-release and /usr/lib/os-release are already quite established.

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

* [Qemu-devel] (no subject)
@ 2017-02-24 13:19 Eric Bischoff
  0 siblings, 0 replies; 133+ messages in thread
From: Eric Bischoff @ 2017-02-24 13:19 UTC (permalink / raw)
  To: qemu-devel

(forgot to CC the list, already sent to Richard Henderson and Alexander Graf)

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

* [Qemu-devel] (no subject)
@ 2017-02-17 15:42 Pranith Kumar
  0 siblings, 0 replies; 133+ messages in thread
From: Pranith Kumar @ 2017-02-17 15:42 UTC (permalink / raw)
  To: alex.bennee; +Cc: qemu-devel, rth, peter.maydell

Subject: [PATCH] aarch64: Change ext type to TCGType to fix warnings

To fix the following warnings:

In file included from /users/pranith/qemu/tcg/tcg.c:255:
/users/pranith/qemu/tcg/aarch64/tcg-target.inc.c:879:24: warning: implicit conversion from enumeration type 'TCGMemOp' (aka 'enum TCGMemOp') to different enumeration type 'TCGType' (aka 'enum TCGType')
      [-Wenum-conversion]
        tcg_out_cmp(s, ext, a, b, b_const);
        ~~~~~~~~~~~    ^~~
/users/pranith/qemu/tcg/aarch64/tcg-target.inc.c:893:36: warning: implicit conversion from enumeration type 'TCGMemOp' (aka 'enum TCGMemOp') to different enumeration type 'TCGType' (aka 'enum TCGType')
      [-Wenum-conversion]
        tcg_out_insn(s, 3201, CBZ, ext, a, offset);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/users/pranith/qemu/tcg/aarch64/tcg-target.inc.c:389:65: note: expanded from macro 'tcg_out_insn'
    glue(tcg_out_insn_,FMT)(S, glue(glue(glue(I,FMT),_),OP), ## __VA_ARGS__)
                                                                ^
/users/pranith/qemu/tcg/aarch64/tcg-target.inc.c:895:37: warning: implicit conversion from enumeration type 'TCGMemOp' (aka 'enum TCGMemOp') to different enumeration type 'TCGType' (aka 'enum TCGType')
      [-Wenum-conversion]
        tcg_out_insn(s, 3201, CBNZ, ext, a, offset);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/users/pranith/qemu/tcg/aarch64/tcg-target.inc.c:389:65: note: expanded from macro 'tcg_out_insn'
    glue(tcg_out_insn_,FMT)(S, glue(glue(glue(I,FMT),_),OP), ## __VA_ARGS__)
                                                                ^
/users/pranith/qemu/tcg/aarch64/tcg-target.inc.c:1610:27: warning: implicit conversion from enumeration type 'TCGType' (aka 'enum TCGType') to different enumeration type 'TCGMemOp' (aka 'enum TCGMemOp')
      [-Wenum-conversion]
        tcg_out_brcond(s, ext, a2, a0, a1, const_args[1], arg_label(args[3]));
        ~~~~~~~~~~~~~~    ^~~

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 tcg/aarch64/tcg-target.inc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c
index 6d227a5a6a..290de6dae6 100644
--- a/tcg/aarch64/tcg-target.inc.c
+++ b/tcg/aarch64/tcg-target.inc.c
@@ -866,7 +866,7 @@ static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l)
     }
 }
 
-static void tcg_out_brcond(TCGContext *s, TCGMemOp ext, TCGCond c, TCGArg a,
+static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a,
                            TCGArg b, bool b_const, TCGLabel *l)
 {
     intptr_t offset;
@@ -937,7 +937,7 @@ static void tcg_out_addsubi(TCGContext *s, int ext, TCGReg rd,
     }
 }
 
-static inline void tcg_out_addsub2(TCGContext *s, int ext, TCGReg rl,
+static inline void tcg_out_addsub2(TCGContext *s, TCGType ext, TCGReg rl,
                                    TCGReg rh, TCGReg al, TCGReg ah,
                                    tcg_target_long bl, tcg_target_long bh,
                                    bool const_bl, bool const_bh, bool sub)
-- 
2.11.0

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

* Re: [Qemu-devel] (no subject)
  2017-01-02 12:03 morgenlette madeBy
@ 2017-01-03 16:36 ` Stefan Hajnoczi
  0 siblings, 0 replies; 133+ messages in thread
From: Stefan Hajnoczi @ 2017-01-03 16:36 UTC (permalink / raw)
  To: morgenlette madeBy; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

On Mon, Jan 02, 2017 at 09:03:55PM +0900, morgenlette madeBy wrote:
> I got problem using QEMU.
> 
> when i turn on virtual machine,
> 
> this message was shown,
> 
> 
> virsh: error while loading shared libraries: libapparmor.so.1: cannot open
> shared object file: No such file or directory
> 
> I have no idea about libapparmor.
> 
> 
> What should I do?

Hi,
Looks like the libvirt packages do not have all dependencies installed.

If you are using Ubuntu try "apt-get install libapparmor1" to install
the missing library.  I looked up the package that provides the
"libapparmor.so.1" filename here:
http://packages.ubuntu.com/search?searchon=contents&keywords=libapparmor.so.1&mode=exactfilename&suite=xenial&arch=any

If you have further questions please try asking for help from your Linux
distribution (e.g. #ubuntu on irc.freenode.net) since this question is
not directly related to QEMU.

Good luck,
Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* [Qemu-devel] (no subject)
@ 2017-01-02 12:03 morgenlette madeBy
  2017-01-03 16:36 ` Stefan Hajnoczi
  0 siblings, 1 reply; 133+ messages in thread
From: morgenlette madeBy @ 2017-01-02 12:03 UTC (permalink / raw)
  To: qemu-devel

hello.

I got problem using QEMU.

when i turn on virtual machine,

this message was shown,


virsh: error while loading shared libraries: libapparmor.so.1: cannot open
shared object file: No such file or directory

I have no idea about libapparmor.


What should I do?

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

* Re: [Qemu-devel] (no subject)
  2016-11-16 19:41 Christopher Oliver
@ 2016-11-17  9:15 ` Thomas Huth
  0 siblings, 0 replies; 133+ messages in thread
From: Thomas Huth @ 2016-11-17  9:15 UTC (permalink / raw)
  To: Christopher Oliver, qemu-devel; +Cc: kwolf, qemu-block, mreitz

 Hi Christopher,

On 16.11.2016 20:41, Christopher Oliver wrote:
> This patch (hack?) works around the slowness in SEEK_HOLE for large dense files
> on Linux tmpfs.  It may improve life elsewhere as well, and the penalty of the checks
> should be vanishingly small where it is not needed.
> 
> If I'm subtly (or not so subtly) wrong, please fire back.

When submitting QEMU patches, there are some rules to be followed:
First, please have a look at
 http://qemu-project.org/Contribute/SubmitAPatch#Do_not_send_as_an_attachment
and the other paragraphs there.
Your mail should also have a proper subject, and the Signed-off-by line
should contain your e-mail address.

 Thanks,
  Thomas

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

* [Qemu-devel] (no subject)
@ 2016-11-16 19:41 Christopher Oliver
  2016-11-17  9:15 ` Thomas Huth
  0 siblings, 1 reply; 133+ messages in thread
From: Christopher Oliver @ 2016-11-16 19:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, mreitz, kwolf

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

This patch (hack?) works around the slowness in SEEK_HOLE for large dense files
on Linux tmpfs.  It may improve life elsewhere as well, and the penalty of the checks
should be vanishingly small where it is not needed.

If I'm subtly (or not so subtly) wrong, please fire back.

Sincerely,

-- 
Christopher Oliver <current.input.port@gmail.com>

[-- Attachment #2: qemu-patch --]
[-- Type: application/octet-stream, Size: 2307 bytes --]

The following patch is a work-around for slow SEEK_HOLE on some filesystems.
Specifically, SEEK_HOLE on a dense file on Linux tmpfs is linear time in
the length.  This slows qemu-img to a crawl as it runs SEEK_DATA/SEEK_HOLE
pairs over the length of the image it's reading stepping by small deltas.

The key observation is that if the descriptor is read-only, and there are
no writers anywhere else (that's undefined behavior anyhow, right?), then a
hole seek in the interval from the previous start to the previously found
hole will find the same hole.

Signed-off-by: Christopher Oliver

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 28b47d9..b45defe 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -136,6 +136,8 @@ typedef struct BDRVRawState {
     int type;
     int open_flags;
     size_t buf_align;
+    off_t last_hole;
+    off_t hole_follows;
 
 #ifdef CONFIG_XFS
     bool is_xfs:1;
@@ -470,6 +472,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
 
     s->has_discard = true;
     s->has_write_zeroes = true;
+    s->last_hole = -1;
     bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
     if ((bs->open_flags & BDRV_O_NOCACHE) != 0) {
         s->needs_alignment = true;
@@ -1710,7 +1713,24 @@ static int find_allocation(BlockDriverState *bs, off_t start,
      * H4. offs < 0, errno != ENXIO: we learned nothing
      *     Pretend we know nothing at all, i.e. "forget" about D1.
      */
-    offs = lseek(s->fd, start, SEEK_HOLE);
+    /* Addendum: Since HOLE seeks are expensive on some filesystems
+     * (e.g. tmpfs) and holes don't change when an image is read only,
+     * cache the range from a start to a hold and return that value
+     * for requests in that interval.  Outside of that interval, seek
+     * and cache the new range.
+     */
+    if  ((s->open_flags & (O_RDWR|O_RDONLY)) == O_RDONLY) {
+        if (start <= s->last_hole && start >= s->hole_follows) {
+            offs = lseek(s->fd, s->last_hole, SEEK_SET);
+        } else {
+            offs = lseek(s->fd, start, SEEK_HOLE);
+            s->last_hole = offs;
+            s->hole_follows = start;
+        }
+    } else {
+        offs = lseek(s->fd, start, SEEK_HOLE);
+    }
+
     if (offs < 0) {
         return -errno;          /* D1 and (H3 or H4) */
     }

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

* [Qemu-devel] (no subject)
@ 2016-10-30 15:30 Pradeep Jagadeesh
  0 siblings, 0 replies; 133+ messages in thread
From: Pradeep Jagadeesh @ 2016-10-30 15:30 UTC (permalink / raw)
  To: Greg Kurz, Alberto Garcia; +Cc: Pradeep Jagadeesh, qemu-devel, Claudio Fontana

Date: Sun, 30 Oct 2016 10:53:16 -0400
Subject: [PATCH V8] fsdev: add IO throttle support to fsdev devices

Uses throttling APIs to limit I/O bandwidth and number of operations on the 
devices which use 9p-local driver.

This adds the support for the 9p-local driver.
For now this functionality can be enabled only through qemu cli options.
QMP interface and support to other drivers need further extensions.
To make it simple for other drivers, the throttle code has been put in
separate files.

Signed-off-by: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>
---
 fsdev/Makefile.objs         |   2 +-
 fsdev/file-op-9p.h          |   3 +
 fsdev/qemu-fsdev-opts.c     |  76 ++++++++++++++++++++++++
 fsdev/qemu-fsdev-throttle.c | 139 ++++++++++++++++++++++++++++++++++++++++++++
 fsdev/qemu-fsdev-throttle.h |  39 +++++++++++++
 hw/9pfs/9p-local.c          |   2 +
 hw/9pfs/9p.c                |  10 ++++
 hw/9pfs/cofile.c            |   2 +
 8 files changed, 272 insertions(+), 1 deletion(-)
 create mode 100644 fsdev/qemu-fsdev-throttle.c
 create mode 100644 fsdev/qemu-fsdev-throttle.h

v1 -> v2:

-Fixed FsContext redeclaration issue
-Removed couple of function declarations from 9p-throttle.h
-Fixed some of the .help messages

v2 -> v3:

-Addressed follwing comments by Claudio Fontana
 -Removed redundant memset calls in fsdev_throttle_configure_iolimits function
 -Checking throttle structure validity before initializing other structures
  in fsdev_throttle_configure_iolimits

-Addressed following comments by Greg Kurz
 -Moved the code from 9pfs directory to fsdev directory, because the throttling
  is for the fsdev devices.Renamed the files and functions to fsdev_ from 9pfs_
 -Renamed throttling cli options to throttling.*, as in QMP cli options
 -Removed some of the unwanted .h files from qemu-fsdev-throttle.[ch]
 -Using throttle_enabled() function to set the thottle enabled flag for fsdev.

v3 -> v4:

-Addressed following comments by Alberto Garcia
 -Removed the unwanted locking and other data structures in qemu-fsdev-throttle.[ch]

-Addressed following comments by Greg Kurz
 -Removed fsdev_iolimitsenable/disable functions, instead using throttle_enabled function

v4 -> V5:
 -Fixed the issue with the larger block size accounting.
 (i.e, when the 9pfs mounted using msize=xxx option)

V5 -> V6:
-Addressed the comments by Alberto Garcia
 -Removed the fsdev_throttle_timer_cb()
 -Simplified the  fsdev_throttle_schedule_next_request() as suggested

V6 -> V7:
-Addressed the comments by Alberto Garcia
 -changed the  fsdev_throttle_schedule_next_request() as suggested

v7 -> v8:
-Addressed comments by Alberto Garcia
 -Fixed some indentation issues and split the configure_io_limit function
 -Inlined throttle_timer_check code


diff --git a/fsdev/Makefile.objs b/fsdev/Makefile.objs
index 1b120a4..659df6e 100644
--- a/fsdev/Makefile.objs
+++ b/fsdev/Makefile.objs
@@ -5,7 +5,7 @@ common-obj-y = qemu-fsdev.o 9p-marshal.o 9p-iov-marshal.o
 else
 common-obj-y = qemu-fsdev-dummy.o
 endif
-common-obj-y += qemu-fsdev-opts.o
+common-obj-y += qemu-fsdev-opts.o qemu-fsdev-throttle.o
 
 # Toplevel always builds this; targets without virtio will put it in
 # common-obj-y
diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
index 6db9fea..33fe822 100644
--- a/fsdev/file-op-9p.h
+++ b/fsdev/file-op-9p.h
@@ -17,6 +17,7 @@
 #include <dirent.h>
 #include <utime.h>
 #include <sys/vfs.h>
+#include "qemu-fsdev-throttle.h"
 
 #define SM_LOCAL_MODE_BITS    0600
 #define SM_LOCAL_DIR_MODE_BITS    0700
@@ -74,6 +75,7 @@ typedef struct FsDriverEntry {
     char *path;
     int export_flags;
     FileOperations *ops;
+    FsThrottle fst;
 } FsDriverEntry;
 
 typedef struct FsContext
@@ -83,6 +85,7 @@ typedef struct FsContext
     int export_flags;
     struct xattr_operations **xops;
     struct extended_ops exops;
+    FsThrottle *fst;
     /* fs driver specific data */
     void *private;
 } FsContext;
diff --git a/fsdev/qemu-fsdev-opts.c b/fsdev/qemu-fsdev-opts.c
index 1dd8c7a..395d497 100644
--- a/fsdev/qemu-fsdev-opts.c
+++ b/fsdev/qemu-fsdev-opts.c
@@ -37,6 +37,82 @@ static QemuOptsList qemu_fsdev_opts = {
         }, {
             .name = "sock_fd",
             .type = QEMU_OPT_NUMBER,
+        }, {
+            .name = "throttling.iops-total",
+            .type = QEMU_OPT_NUMBER,
+            .help = "limit total I/O operations per second",
+        },{
+            .name = "throttling.iops-read",
+            .type = QEMU_OPT_NUMBER,
+            .help = "limit read operations per second",
+        },{
+            .name = "throttling.iops-write",
+            .type = QEMU_OPT_NUMBER,
+            .help = "limit write operations per second",
+        },{
+            .name = "throttling.bps-total",
+            .type = QEMU_OPT_NUMBER,
+            .help = "limit total bytes per second",
+        },{
+            .name = "throttling.bps-read",
+            .type = QEMU_OPT_NUMBER,
+            .help = "limit read bytes per second",
+        },{
+            .name = "throttling.bps-write",
+            .type = QEMU_OPT_NUMBER,
+            .help = "limit write bytes per second",
+        },{
+            .name = "throttling.iops-total-max",
+            .type = QEMU_OPT_NUMBER,
+            .help = "I/O operations burst",
+        },{
+            .name = "throttling.iops-read-max",
+            .type = QEMU_OPT_NUMBER,
+            .help = "I/O operations read burst",
+        },{
+            .name = "throttling.iops-write-max",
+            .type = QEMU_OPT_NUMBER,
+            .help = "I/O operations write burst",
+        },{
+            .name = "throttling.bps-total-max",
+            .type = QEMU_OPT_NUMBER,
+            .help = "total bytes burst",
+        },{
+            .name = "throttling.bps-read-max",
+            .type = QEMU_OPT_NUMBER,
+            .help = "total bytes read burst",
+        },{
+            .name = "throttling.bps-write-max",
+            .type = QEMU_OPT_NUMBER,
+            .help = "total bytes write burst",
+        },{
+            .name = "throttling.iops-total-max-length",
+            .type = QEMU_OPT_NUMBER,
+            .help = "length of the iops-total-max burst period, in seconds",
+        },{
+            .name = "throttling.iops-read-max-length",
+            .type = QEMU_OPT_NUMBER,
+            .help = "length of the iops-read-max burst period, in seconds",
+        },{
+            .name = "throttling.iops-write-max-length",
+            .type = QEMU_OPT_NUMBER,
+            .help = "length of the iops-write-max burst period, in seconds",
+        },{
+            .name = "throttling.bps-total-max-length",
+            .type = QEMU_OPT_NUMBER,
+            .help = "length of the bps-total-max burst period, in seconds",
+        },{
+            .name = "throttling.bps-read-max-length",
+            .type = QEMU_OPT_NUMBER,
+            .help = "length of the bps-read-max burst period, in seconds",
+        },{
+            .name = "throttling.bps-write-max-length",
+            .type = QEMU_OPT_NUMBER,
+            .help = "length of the bps-write-max burst period, in seconds",
+        },{
+            .name = "throttling.iops-size",
+            .type = QEMU_OPT_NUMBER,
+            .help = "when limiting by iops max size of an I/O in bytes",
         },
 
         { /*End of list */ }
diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
new file mode 100644
index 0000000..768d27b
--- /dev/null
+++ b/fsdev/qemu-fsdev-throttle.c
@@ -0,0 +1,139 @@
+/*
+ * Fsdev Throttle
+ *
+ * Copyright (C) 2016 Huawei Technologies Duesseldorf GmbH
+ *
+ * Author: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version.
+ *
+ * See the COPYING file in the top-level directory for details.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+#include "qemu-fsdev-throttle.h"
+
+static void fsdev_throttle_schedule_next_request(FsThrottle *fst, bool is_write)
+{
+    if (!qemu_co_queue_empty(&fst->throttled_reqs[is_write])) {
+        if (throttle_schedule_timer(&fst->ts, &fst->tt, is_write)) {
+            return;
+        }
+       qemu_co_queue_next(&fst->throttled_reqs[is_write]);
+   }
+}
+
+static void fsdev_throttle_read_timer_cb(void *opaque)
+{
+    FsThrottle *fst = opaque;
+    qemu_co_enter_next(&fst->throttled_reqs[false]);
+}
+
+static void fsdev_throttle_write_timer_cb(void *opaque)
+{
+    FsThrottle *fst = opaque;
+    qemu_co_enter_next(&fst->throttled_reqs[true]);
+}
+
+void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst)
+{
+    fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg =
+        qemu_opt_get_number(opts, "throttling.bps-total", 0);
+    fst->cfg.buckets[THROTTLE_BPS_READ].avg  =
+        qemu_opt_get_number(opts, "throttling.bps-read", 0);
+    fst->cfg.buckets[THROTTLE_BPS_WRITE].avg =
+        qemu_opt_get_number(opts, "throttling.bps-write", 0);
+    fst->cfg.buckets[THROTTLE_OPS_TOTAL].avg =
+        qemu_opt_get_number(opts, "throttling.iops-total", 0);
+    fst->cfg.buckets[THROTTLE_OPS_READ].avg =
+        qemu_opt_get_number(opts, "throttling.iops-read", 0);
+    fst->cfg.buckets[THROTTLE_OPS_WRITE].avg =
+        qemu_opt_get_number(opts, "throttling.iops-write", 0);
+
+    fst->cfg.buckets[THROTTLE_BPS_TOTAL].max =
+        qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
+    fst->cfg.buckets[THROTTLE_BPS_READ].max  =
+        qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
+    fst->cfg.buckets[THROTTLE_BPS_WRITE].max =
+        qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
+    fst->cfg.buckets[THROTTLE_OPS_TOTAL].max =
+        qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
+    fst->cfg.buckets[THROTTLE_OPS_READ].max =
+        qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
+    fst->cfg.buckets[THROTTLE_OPS_WRITE].max =
+        qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
+
+    fst->cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =
+        qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1);
+    fst->cfg.buckets[THROTTLE_BPS_READ].burst_length  =
+        qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1);
+    fst->cfg.buckets[THROTTLE_BPS_WRITE].burst_length =
+        qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1);
+    fst->cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =
+        qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1);
+    fst->cfg.buckets[THROTTLE_OPS_READ].burst_length =
+        qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1);
+    fst->cfg.buckets[THROTTLE_OPS_WRITE].burst_length =
+        qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1);
+    fst->cfg.op_size =
+        qemu_opt_get_number(opts, "throttling.iops-size", 0);
+}
+
+int fsdev_throttle_init(FsThrottle *fst)
+{
+    Error *err = NULL;
+
+    if (!throttle_is_valid(&fst->cfg, &err)) {
+        error_reportf_err(err, "Throttle configuration is not valid: ");
+        return -1;
+    }
+    if (throttle_enabled(&fst->cfg)) {
+        g_assert((fst->aioctx = qemu_get_aio_context()));
+        throttle_init(&fst->ts);
+        throttle_timers_init(&fst->tt,
+                             fst->aioctx,
+                             QEMU_CLOCK_REALTIME,
+                             fsdev_throttle_read_timer_cb,
+                             fsdev_throttle_write_timer_cb,
+                             fst);
+        throttle_config(&fst->ts, &fst->tt, &fst->cfg);
+        qemu_co_queue_init(&fst->throttled_reqs[0]);
+        qemu_co_queue_init(&fst->throttled_reqs[1]);
+    }
+    return 0;
+}
+
+static uint64_t get_num_bytes(struct iovec *iov, int iovcnt)
+{
+    int i;
+    uint64_t bytes = 0;
+
+    for (i = 0; i < iovcnt; i++) {
+        bytes += iov[i].iov_len;
+    }
+    return bytes;
+}
+
+void coroutine_fn fsdev_co_throttle_request(FsThrottle *fst, bool is_write,
+                                            struct iovec *iov, int iovcnt)
+{
+    if (throttle_enabled(&fst->cfg)) {
+        uint64_t bytes = get_num_bytes(iov, iovcnt);
+        bool must_wait = throttle_schedule_timer(&fst->ts, &fst->tt, is_write);
+        if (must_wait || !qemu_co_queue_empty(&fst->throttled_reqs[is_write])) {
+            qemu_co_queue_wait(&fst->throttled_reqs[is_write]);
+        }
+        throttle_account(&fst->ts, is_write, bytes);
+
+        fsdev_throttle_schedule_next_request(fst, is_write);
+    }
+}
+
+void fsdev_throttle_cleanup(FsThrottle *fst)
+{
+    throttle_timers_destroy(&fst->tt);
+}
diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h
new file mode 100644
index 0000000..bafb340
--- /dev/null
+++ b/fsdev/qemu-fsdev-throttle.h
@@ -0,0 +1,39 @@
+/*
+ * Fsdev Throttle
+ *
+ * Copyright (C) 2016 Huawei Technologies Duesseldorf GmbH
+ *
+ * Author: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version.
+ *
+ * See the COPYING file in the top-level directory for details.
+ *
+ */
+
+#ifndef _FSDEV_THROTTLE_H
+#define _FSDEV_THROTTLE_H
+
+#include "block/aio.h"
+#include "qemu/main-loop.h"
+#include "qemu/coroutine.h"
+#include "qemu/throttle.h"
+
+typedef struct FsThrottle {
+    ThrottleState ts;
+    ThrottleTimers tt;
+    AioContext   *aioctx;
+    ThrottleConfig cfg;
+    CoQueue      throttled_reqs[2];
+} FsThrottle;
+
+void fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *);
+
+int  fsdev_throttle_init(FsThrottle *);
+
+void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool ,
+                                            struct iovec *, int);
+
+void fsdev_throttle_cleanup(FsThrottle *);
+#endif /* _FSDEV_THROTTLE_H */
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 845675e..842b82e 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1237,6 +1237,8 @@ static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
         error_report("fsdev: No path specified");
         return -1;
     }
+
+    fsdev_throttle_parse_opts(opts, &fse->fst);
     fse->path = g_strdup(path);
 
     return 0;
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index e88cf25..450ed12 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3506,6 +3506,13 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
         error_setg(errp, "share path %s is not a directory", fse->path);
         goto out;
     }
+
+    s->ctx.fst = &fse->fst;
+    if (fsdev_throttle_init(s->ctx.fst) < 0) {
+        error_report("fsdev: Throttle configuration specified is not valid");
+        return -1;
+    }
+
     v9fs_path_free(&path);
 
     rc = 0;
@@ -3520,6 +3527,9 @@ out:
 
 void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
 {
+    if (throttle_enabled(&s->ctx.fst->cfg)) {
+        fsdev_throttle_cleanup(s->ctx.fst);
+    }
     g_free(s->ctx.fs_root);
     g_free(s->tag);
 }
diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
index 120e267..88791bc 100644
--- a/hw/9pfs/cofile.c
+++ b/hw/9pfs/cofile.c
@@ -247,6 +247,7 @@ int coroutine_fn v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
     if (v9fs_request_cancelled(pdu)) {
         return -EINTR;
     }
+    fsdev_co_throttle_request(s->ctx.fst, true, iov, iovcnt);
     v9fs_co_run_in_worker(
         {
             err = s->ops->pwritev(&s->ctx, &fidp->fs, iov, iovcnt, offset);
@@ -266,6 +267,7 @@ int coroutine_fn v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp,
     if (v9fs_request_cancelled(pdu)) {
         return -EINTR;
     }
+    fsdev_co_throttle_request(s->ctx.fst, false, iov, iovcnt);
     v9fs_co_run_in_worker(
         {
             err = s->ops->preadv(&s->ctx, &fidp->fs, iov, iovcnt, offset);
-- 
1.8.3.1

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

* [Qemu-devel] (no subject)
@ 2016-10-20  6:59 Nicholas Piggin
  0 siblings, 0 replies; 133+ messages in thread
From: Nicholas Piggin @ 2016-10-20  6:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nicholas Piggin, qemu-ppc, Alexey Kardashevskiy, David Gibson,
	Alexander Graf


Date: Thu, 20 Oct 2016 17:38:24 +1100
Subject: [PATCH 0/3] ppc: system reset interrupt fixes and new hcall IPI

Hi,

We are implementing this new unmaskable IPI hcall for crash dumping
and debugging. I had some issues with QEMU delivering system reset
interrupt to guests, which was caused by the HV bit being set. After
changing that, the interrupt was being handled okay. Should there be
a more general check to ensure the HV bit is not set in the guest?

I implemented Linux support for the new hcall in crashdump code, and
it works.

Thanks,
Nick

Nicholas Piggin (3):
  ppc: fix MSR_ME handling for system reset interrupt
  ppc: allow system reset interrupt to be delivered to guests
  ppc/spapr: implement H_SIGNAL_SYS_RESET

 hw/ppc/spapr_hcall.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr.h   |  8 +++++++-
 target-ppc/excp_helper.c | 10 +++++++---
 3 files changed, 56 insertions(+), 4 deletions(-)

-- 
2.9.3

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

* [Qemu-devel] (no subject)
@ 2016-10-12 21:49 Neeraj Sharma
  0 siblings, 0 replies; 133+ messages in thread
From: Neeraj Sharma @ 2016-10-12 21:49 UTC (permalink / raw)
  To: qemu-devel

Dear Sir/Ma'am

I want to ‘annotate’ the translation buffers - (adding a mechanism in the
translation buffers where we can store how many times they were executed,
and, for each one, add some ‘amount’ could be power, could be anything). I
need held to understand the translation buffer code in qemu, starts fom
cpu-exec.c.

Neeraj
Thanks

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

* [Qemu-devel] (no subject)
@ 2016-10-02  6:47 Shreya Shrivastava
  0 siblings, 0 replies; 133+ messages in thread
From: Shreya Shrivastava @ 2016-10-02  6:47 UTC (permalink / raw)
  To: stefanha; +Cc: qemu-devel

HI ,

I am interested in applying for Outreachy 2016 December- March round by
contributing to  VIRTIO 1.0 support in libqos project for Qemu.

Kindly let me know how to get started with this project.

Shreya Shrivastava

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

* Re: [Qemu-devel] (no subject)
  2016-09-13  2:28 ` Fam Zheng
@ 2016-09-19 15:54   ` Stephen Bates
  0 siblings, 0 replies; 133+ messages in thread
From: Stephen Bates @ 2016-09-19 15:54 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel

Hi Fam

Thanks! Yes gdb provides one approach but I was wondering if there was something built in to QEMU monitor.

Another application I can see for this would be to inject errors into the memory, This will be useful for testing new NVDIMM-P technology that builds NVDIMMs out of material that is less reliable than DRAM...

Cheers

Stephen

> On Sep 12, 2016, at 7:28 PM, Fam Zheng <famz@redhat.com> wrote:
> 
>> On Mon, 09/12 16:23, Stephen Bates wrote:
>> Hi
> 
> Hi Stephen,
> 
>> 
>> I sent this to qemu-discuss with no success so resending to qemu-devel.
>> 
>> I am doing some very low level OS design work and wanted to be able to
>> alter some values in the physical memory of my QEMU guest. I can see quite
>> a few ways to print/dump both physical and virtual addresses but nothing
>> that can alter arbitrary physical/virtual addresses?
>> 
>> Does such a feature exist in Qemu and if it does are there pointers to
>> documentation for it?
> 
> Have you tried the builtin gdbstub in QEMU? You can add "-s" to the QEMU
> command line and then connect to it from gdb with "target remote :1234". There
> you can inspect or change memory more easily.
> 
> Fam
> 
>> 
>> I do see that we can use file backing for very large memory regions via
>> the memory-backing-file option but I am not really trying to alter massive
>> regions of memory in this case.
>> 
>> Cheers
>> 
>> Stephen Bates
>> 

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

* Re: [Qemu-devel] (no subject)
  2016-09-12 21:23 Stephen Bates
@ 2016-09-13  2:28 ` Fam Zheng
  2016-09-19 15:54   ` Stephen Bates
  0 siblings, 1 reply; 133+ messages in thread
From: Fam Zheng @ 2016-09-13  2:28 UTC (permalink / raw)
  To: Stephen Bates; +Cc: qemu-devel

On Mon, 09/12 16:23, Stephen Bates wrote:
> Hi

Hi Stephen,

> 
> I sent this to qemu-discuss with no success so resending to qemu-devel.
> 
> I am doing some very low level OS design work and wanted to be able to
> alter some values in the physical memory of my QEMU guest. I can see quite
> a few ways to print/dump both physical and virtual addresses but nothing
> that can alter arbitrary physical/virtual addresses?
> 
> Does such a feature exist in Qemu and if it does are there pointers to
> documentation for it?

Have you tried the builtin gdbstub in QEMU? You can add "-s" to the QEMU
command line and then connect to it from gdb with "target remote :1234". There
you can inspect or change memory more easily.

Fam

> 
> I do see that we can use file backing for very large memory regions via
> the memory-backing-file option but I am not really trying to alter massive
> regions of memory in this case.
> 
> Cheers
> 
> Stephen Bates
> 

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

* [Qemu-devel] (no subject)
@ 2016-09-12 21:23 Stephen Bates
  2016-09-13  2:28 ` Fam Zheng
  0 siblings, 1 reply; 133+ messages in thread
From: Stephen Bates @ 2016-09-12 21:23 UTC (permalink / raw)
  To: qemu-devel

Hi

I sent this to qemu-discuss with no success so resending to qemu-devel.

I am doing some very low level OS design work and wanted to be able to
alter some values in the physical memory of my QEMU guest. I can see quite
a few ways to print/dump both physical and virtual addresses but nothing
that can alter arbitrary physical/virtual addresses?

Does such a feature exist in Qemu and if it does are there pointers to
documentation for it?

I do see that we can use file backing for very large memory regions via
the memory-backing-file option but I am not really trying to alter massive
regions of memory in this case.

Cheers

Stephen Bates

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

* [Qemu-devel] (no subject)
@ 2016-07-31 15:07 Kumud Bhat
  0 siblings, 0 replies; 133+ messages in thread
From: Kumud Bhat @ 2016-07-31 15:07 UTC (permalink / raw)
  To: qemu-devel

*Kumud Bhat*
Department of Computer and Information science
Purdue School of Science,IUPUI
Indianapolis-IN, United States

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

* Re: [Qemu-devel] (no subject)
  2016-03-21 21:09   ` Peter Maydell
@ 2016-03-22 21:45     ` John Snow
  0 siblings, 0 replies; 133+ messages in thread
From: John Snow @ 2016-03-22 21:45 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Yunqiang Gao



On 03/21/2016 05:09 PM, Peter Maydell wrote:
> On 21 March 2016 at 18:00, John Snow <jsnow@redhat.com> wrote:
>> Looks like one of your libraries is outdated, for me
>> 'IBV_LINK_LAYER_INFINIBAND' is defined in
>> /usr/include/infiniband/verbs.h; provided by
>> libibverbs-devel-1.1.8-3.fc22.x86_64.
>>
>> Maybe your libibverbs is too old.
> 
> We should probably add a suitable configure test.
> 
> thanks
> -- PMM
> 

Sure, I don't know formally what our minimum version requirement for
libibverbs is.

In this case at least,
http://git.kernel.org/cgit/libs/infiniband/libibverbs.git/commit/include/infiniband/verbs.h?id=e5df8c64df6877facc045608a25f4d4fecd5f2b0

committed 2011-07-26 20:15:33 (GMT),

so probably:
http://git.kernel.org/cgit/libs/infiniband/libibverbs.git/commit/?id=8b2ffc598bd7f8294f3653cab430146985040739

libibverbs 1.1.6 (December 2011) as a minimum, unless there's an even
newer requirement?

--js

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

* Re: [Qemu-devel] (no subject)
  2016-03-21 18:00 ` John Snow
@ 2016-03-21 21:09   ` Peter Maydell
  2016-03-22 21:45     ` John Snow
  0 siblings, 1 reply; 133+ messages in thread
From: Peter Maydell @ 2016-03-21 21:09 UTC (permalink / raw)
  To: John Snow; +Cc: qemu-devel, Yunqiang Gao

On 21 March 2016 at 18:00, John Snow <jsnow@redhat.com> wrote:
> Looks like one of your libraries is outdated, for me
> 'IBV_LINK_LAYER_INFINIBAND' is defined in
> /usr/include/infiniband/verbs.h; provided by
> libibverbs-devel-1.1.8-3.fc22.x86_64.
>
> Maybe your libibverbs is too old.

We should probably add a suitable configure test.

thanks
-- PMM

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

* Re: [Qemu-devel] (no subject)
  2016-03-21  8:44 Yunqiang Gao
@ 2016-03-21 18:00 ` John Snow
  2016-03-21 21:09   ` Peter Maydell
  0 siblings, 1 reply; 133+ messages in thread
From: John Snow @ 2016-03-21 18:00 UTC (permalink / raw)
  To: Yunqiang Gao, qemu-devel



On 03/21/2016 04:44 AM, Yunqiang Gao wrote:
> Hi,alls,
> 
>  I compile qemu on ubuntu 12.04,when "make",some error appears.the error:
> 
> migration/rdma.c: In function ‘qemu_rdma_dump_id’:
> migration/rdma.c:738:21: error: ‘struct ibv_port_attr’ has no member
> named ‘link_layer’
> migration/rdma.c:739:22: error: ‘struct ibv_port_attr’ has no member
> named ‘link_layer’
> migration/rdma.c:739:37: error: ‘IBV_LINK_LAYER_INFINIBAND’ undeclared
> (first use in this function)
> migration/rdma.c:739:37: note: each undeclared identifier is reported
> only once for each function it appears in
> migration/rdma.c:740:24: error: ‘struct ibv_port_attr’ has no member
> named ‘link_layer’
> migration/rdma.c:740:39: error: ‘IBV_LINK_LAYER_ETHERNET’ undeclared
> (first use in this function)
> migration/rdma.c: In function ‘qemu_rdma_broken_ipv6_kernel’:
> migration/rdma.c:839:26: error: ‘struct ibv_port_attr’ has no member
> named ‘link_layer’
> migration/rdma.c:839:41: error: ‘IBV_LINK_LAYER_INFINIBAND’ undeclared
> (first use in this function)
> migration/rdma.c:841:33: error: ‘struct ibv_port_attr’ has no member
> named ‘link_layer’
> migration/rdma.c:841:48: error: ‘IBV_LINK_LAYER_ETHERNET’ undeclared
> (first use in this function)
> migration/rdma.c:880:18: error: ‘struct ibv_port_attr’ has no member
> named ‘link_layer’
> make: *** [migration/rdma.o] Error 1
> 
> I have do that: apt-get build-dep qemu.
> 
> when I install Recommended additional packages,two packages can't be
> installed,these are libseccomp-dev,libvdeplug-dev.
> errpr information:
> Reading package lists... Done
> Building dependency tree       
> Reading state information... Done
> E: Unable to locate package libvdeplug-dev
> 
> my linux kernel is 4.4.1.
> 
> Could anybody know how to deal with it?
> 
> Thanks!
> 

If you don't need the RDMA feature, you could always just --disable-rdma
for now to see if you can get QEMU to build.

Looks like one of your libraries is outdated, for me
'IBV_LINK_LAYER_INFINIBAND' is defined in
/usr/include/infiniband/verbs.h; provided by
libibverbs-devel-1.1.8-3.fc22.x86_64.

Maybe your libibverbs is too old.

--js

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

* [Qemu-devel] (no subject)
@ 2016-03-21  8:44 Yunqiang Gao
  2016-03-21 18:00 ` John Snow
  0 siblings, 1 reply; 133+ messages in thread
From: Yunqiang Gao @ 2016-03-21  8:44 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]

Hi,alls,

 I compile qemu on ubuntu 12.04,when "make",some error appears.the error:

migration/rdma.c: In function ‘qemu_rdma_dump_id’:
migration/rdma.c:738:21: error: ‘struct ibv_port_attr’ has no member named
‘link_layer’
migration/rdma.c:739:22: error: ‘struct ibv_port_attr’ has no member named
‘link_layer’
migration/rdma.c:739:37: error: ‘IBV_LINK_LAYER_INFINIBAND’ undeclared
(first use in this function)
migration/rdma.c:739:37: note: each undeclared identifier is reported only
once for each function it appears in
migration/rdma.c:740:24: error: ‘struct ibv_port_attr’ has no member named
‘link_layer’
migration/rdma.c:740:39: error: ‘IBV_LINK_LAYER_ETHERNET’ undeclared (first
use in this function)
migration/rdma.c: In function ‘qemu_rdma_broken_ipv6_kernel’:
migration/rdma.c:839:26: error: ‘struct ibv_port_attr’ has no member named
‘link_layer’
migration/rdma.c:839:41: error: ‘IBV_LINK_LAYER_INFINIBAND’ undeclared
(first use in this function)
migration/rdma.c:841:33: error: ‘struct ibv_port_attr’ has no member named
‘link_layer’
migration/rdma.c:841:48: error: ‘IBV_LINK_LAYER_ETHERNET’ undeclared (first
use in this function)
migration/rdma.c:880:18: error: ‘struct ibv_port_attr’ has no member named
‘link_layer’
make: *** [migration/rdma.o] Error 1

I have do that: apt-get build-dep qemu.

when I install Recommended additional packages,two packages can't be
installed,these are libseccomp-dev,libvdeplug-dev.
errpr information:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libvdeplug-dev

my linux kernel is 4.4.1.

Could anybody know how to deal with it?

Thanks!

[-- Attachment #2: Type: text/html, Size: 4324 bytes --]

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

* [Qemu-devel] (no subject)
@ 2016-01-15 10:06 Liang Li
  0 siblings, 0 replies; 133+ messages in thread
From: Liang Li @ 2016-01-15 10:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: amit.shah, zhang.zhanghailiang, Liang Li, dgilbert, quintela

Subject: [PATCH RESEND v2 0/2] Fix flaw of qemu_put_compression_data

The implementation of qemu_put_compression_data only consider the case
QEMUFile is writable, it can't work with a writable QEMUFile and does
not provide any measure to prevent users from using it with a writable
QEMUFile. For safety, it should be improved to avoid some issues.

ram_save_compressed_page can be refined based on the change of
qemu_put_compression_data, very small improvement, but code looks better.

Liang Li (2):
  qemu-file: Fix qemu_put_compression_data flaw
  migration: refine ram_save_compressed_page

 migration/qemu-file.c | 23 +++++++++++++++++++++--
 migration/ram.c       | 20 ++++++++------------
 2 files changed, 29 insertions(+), 14 deletions(-)

-- 
1.9.1

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

* Re: [Qemu-devel] (no subject)
  2015-11-17 13:08 Christoph Hellwig
@ 2015-11-17 17:29 ` Paolo Bonzini
  0 siblings, 0 replies; 133+ messages in thread
From: Paolo Bonzini @ 2015-11-17 17:29 UTC (permalink / raw)
  To: Christoph Hellwig, Keith Busch; +Cc: qemu-devel, qemu-block



On 17/11/2015 14:08, Christoph Hellwig wrote:
> below is a fix for a bug in the qemu NVMe identify implementation that's
> causing us some trouble with an updated Linux driver.  We'll have to
> blacklist the existing Qemu device ID for it, so I wonder how we can
> advertize a fixed controller.  Maybe a new PCI ID?  Or maybe just bump
> the PCI revision, altough that would be a bit more complicated in the
> driver.

Bumping the PCI revision would be ideal, but I guess the PCI ID would
work too if it's really that bad.

Paolo

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

* [Qemu-devel] (no subject)
@ 2015-11-17 13:08 Christoph Hellwig
  2015-11-17 17:29 ` Paolo Bonzini
  0 siblings, 1 reply; 133+ messages in thread
From: Christoph Hellwig @ 2015-11-17 13:08 UTC (permalink / raw)
  To: Keith Busch; +Cc: qemu-devel, qemu-block

From: Christoph Hellwig <hch@lst.de>
Subject: a nasty nvme fix
In-Reply-To: 

Hi all,

below is a fix for a bug in the qemu NVMe identify implementation that's
causing us some trouble with an updated Linux driver.  We'll have to
blacklist the existing Qemu device ID for it, so I wonder how we can
advertize a fixed controller.  Maybe a new PCI ID?  Or maybe just bump
the PCI revision, altough that would be a bit more complicated in the
driver.

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

* [Qemu-devel] (no subject)
@ 2015-07-14  7:33 Pankaj Gupta
  0 siblings, 0 replies; 133+ messages in thread
From: Pankaj Gupta @ 2015-07-14  7:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: amit.shah, Pankaj Gupta, mst

Subject: [PATCH 0/2 v2] virtio-rng: Avoid uncessary timer trigger to bump up quota value 

Timer was added in virtio-rng to rate limit the
entropy. It used to trigger at regular intervals to
bump up the quota value. The value of quota and timer
is used to ensure single guest should not use up all the 
entropy from the host.
This resulted in triggering of timer even when quota
is not exhausted at all and resulting in extra processing.

This series has two patches:

patch1 : Bump up quota value only when guest requests entropy.
patch2 : Serve pending request if any after timer bumps up quota.

Changes from v1:
Amit Shah : 
            Serve pending request if any after timer bumps up quota.
            Add testing details.

I tested this with '/dev/urandom' at host side. Below are the details:

* Quota+timer specified on command line, 
  Ran in Guest 'dd if=/dev/hwrng of=/dev/null'
  
  - Quota (4096 bytes), Time slice (1000 ms)

    48152 bytes (49 KB) copied, 12.0005 s, 4.1 kB/s
    48640 bytes (49 KB) copied, 12.0014 s, 4.1 kB/s

  - Quota (8192), Time slice (1000 ms)
    65536 bytes  (66 KB) copied, 8.00088 s, 8.2 kB/s
    146944 bytes (147 KB)copied, 18.0021 s, 8.2 kB/s

  - No quota/timer specified on command line, takes default values.
    Quota (INT64_MAX), Time slice(65536 ms)
    8050688 bytes (8.1 MB) copied, 93.1198 s, 86.5 kB/s
    35568128 bytes (36 MB) copied, 408.823 s, 87.0 kB/s


 hw/virtio/virtio-rng.c         |   51 +++++++++++++++++++++++++----------------
 include/hw/virtio/virtio-rng.h |    1 
 2 files changed, 33 insertions(+), 19 deletions(-)

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

* [Qemu-devel] (no subject)
@ 2015-07-02 16:18 Denis V. Lunev
  0 siblings, 0 replies; 133+ messages in thread
From: Denis V. Lunev @ 2015-07-02 16:18 UTC (permalink / raw)
  Cc: Peter Maydell, Pavel Butsykin, qemu-devel, Luiz Capitulino,
	Paolo Bonzini, Denis V. Lunev

The monivation of this set is simple. Recently we have proposed patch
to monitor.c with specific x86 APIC HMP commands. The patchset was denied
with the main motivation "No more arch specific code in monitor.c"
This patchset is the first step to move arch specific code from
monitor.c targets.

So, monitor.c already contains a lot of generic code, as well as the target
specifics code and eventually monitor.c volume will only grow. This trend leads
to a variety of fouling code ifdeffery(and combinations thereof),
poor readability, and entanglement of architecture of the project.
If someone wants to improve processing logic commands at the monitor,
it isn't necessarily must differentiate amongst the implementation of some ARM
or x86_64 specific commands, because the project already has separation of
target specific code on directories.

The presented solution is not the best, but it is quite simple
(PATCH doesn't add more code!) and decides the above mentioned issue.
Subsequently it will not prevent the introduction of more advanced mechanism
that can more effectively resolve the issue.

There is a issue with the placement of code for multiple architectures
(isn't for everyone), but this code is very small. This patch is a step towards
solving the issue associated with maintaining the purity of the code and
structure of the project, which solves not all, but doing a little better
than it is.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Luiz Capitulino <lcapitulino@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Peter Maydell <peter.maydell@linaro.org>

Pavel Butsykin (3):
  hmp-commands-info: move info_cmds content out of monitor.c
  monitor: remove target-specific code from monitor.c
  monitor: added generation of documentation for  hmp-commands-info.hx

 .gitignore                       |    1 +
 Makefile                         |    9 +-
 Makefile.target                  |    5 +-
 hmp-commands-info.hx             |  715 ++++++++++++++++++++++
 hmp-commands.hx                  |  120 ----
 include/monitor/monitor-common.h |   43 ++
 monitor.c                        | 1227 +-------------------------------------
 qemu-doc.texi                    |    2 +
 target-i386/Makefile.objs        |    2 +-
 target-i386/monitor.c            |  489 +++++++++++++++
 target-ppc/Makefile.objs         |    2 +-
 target-ppc/monitor.c             |  250 ++++++++
 target-sh4/Makefile.objs         |    1 +
 target-sh4/monitor.c             |   52 ++
 target-sparc/Makefile.objs       |    2 +-
 target-sparc/monitor.c           |  153 +++++
 target-xtensa/Makefile.objs      |    1 +
 target-xtensa/monitor.c          |   34 ++
 18 files changed, 1762 insertions(+), 1346 deletions(-)
 create mode 100644 hmp-commands-info.hx
 create mode 100644 include/monitor/monitor-common.h
 create mode 100644 target-i386/monitor.c
 create mode 100644 target-ppc/monitor.c
 create mode 100644 target-sh4/monitor.c
 create mode 100644 target-sparc/monitor.c
 create mode 100644 target-xtensa/monitor.c

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

* Re: [Qemu-devel] (no subject)
  2015-06-30  7:18 ` Fam Zheng
@ 2015-06-30 14:22   ` Scott Feldman
  0 siblings, 0 replies; 133+ messages in thread
From: Scott Feldman @ 2015-06-30 14:22 UTC (permalink / raw)
  To: Fam Zheng; +Cc: Jiří Pírko, QEMU Developers, Stefan Hajnoczi

On Tue, Jun 30, 2015 at 3:18 AM, Fam Zheng <famz@redhat.com> wrote:
> On Tue, 06/30 00:49, Scott Feldman wrote:
>> Hi Fam, Stefan,
>>
>> I'm running a test with rocker device using UDP sockets connections
>> and I'm seeing the socket s->read_poll stay disabled if the device
>> receives a packet when the device's can_receive returns false.
>> Receive is stuck after that; nothing ever re-enables s->read_poll.  I
>> see the first packet queued on queue->packets and that's it.   No more
>> receives.  If I modify the device to lie and always return
>> can_receive=true, and drop the pkt in driver receive, then things work
>> fine.
>>
>> I think this patch broke can_receive semantics for net/socket.c:
>
> Yes. The semantics now is if .can_receive returns false, the NIC needs to flush
> the queue explicitly when the conditions in .can_receive become true, because
> net/{socket,tap,...} no longer polls .can_receive().

Ah, that makes sense.

>> commit 6e99c631f116221d169ea53953d91b8aa74d297a
>> Author: Fam Zheng <famz@redhat.com>
>> Date:   Thu Jun 4 14:45:16 2015 +0800
>>
>>     net/socket: Drop net_socket_can_send
>>
>> Anything jump out?
>>
>> (In the test, rocker device is enabling the netdev port once the guest
>> OS driver signals to enable the port based on STP process running on
>> the guest.  The initial STP state is DISABLED, so the port is isolated
>> from the network.  As STP algo progresses, the port is opened up and
>> the netdev is enabled for Rx traffic).
>>
>> -scott
>>
>
> Does dropping .can_receive or forcing 1 work for you? Or maybe something like
> this:

Dropping .can_receive works.  Actually, we really don't want any pkts
queued when the device port is disabled, otherwise when the port
transitions to enabled, we'll receive stale network pkts.  This would
be bad for a switch device.  So I think this is a happy outcome:
removing .can_receive prevents pkt queuing on the backend, and the
.receive handler can eat the pkt if the port is disabled.  I'll send a
rocker patch to fix this.  Thanks Fam.

-scott

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

* Re: [Qemu-devel] (no subject)
  2015-06-30  4:49 Scott Feldman
@ 2015-06-30  7:18 ` Fam Zheng
  2015-06-30 14:22   ` Scott Feldman
  0 siblings, 1 reply; 133+ messages in thread
From: Fam Zheng @ 2015-06-30  7:18 UTC (permalink / raw)
  To: Scott Feldman; +Cc: Jiří Pírko, QEMU Developers, Stefan Hajnoczi

On Tue, 06/30 00:49, Scott Feldman wrote:
> Hi Fam, Stefan,
> 
> I'm running a test with rocker device using UDP sockets connections
> and I'm seeing the socket s->read_poll stay disabled if the device
> receives a packet when the device's can_receive returns false.
> Receive is stuck after that; nothing ever re-enables s->read_poll.  I
> see the first packet queued on queue->packets and that's it.   No more
> receives.  If I modify the device to lie and always return
> can_receive=true, and drop the pkt in driver receive, then things work
> fine.
> 
> I think this patch broke can_receive semantics for net/socket.c:

Yes. The semantics now is if .can_receive returns false, the NIC needs to flush
the queue explicitly when the conditions in .can_receive become true, because
net/{socket,tap,...} no longer polls .can_receive().
> 
> commit 6e99c631f116221d169ea53953d91b8aa74d297a
> Author: Fam Zheng <famz@redhat.com>
> Date:   Thu Jun 4 14:45:16 2015 +0800
> 
>     net/socket: Drop net_socket_can_send
> 
> Anything jump out?
> 
> (In the test, rocker device is enabling the netdev port once the guest
> OS driver signals to enable the port based on STP process running on
> the guest.  The initial STP state is DISABLED, so the port is isolated
> from the network.  As STP algo progresses, the port is opened up and
> the netdev is enabled for Rx traffic).
> 
> -scott
> 

Does dropping .can_receive or forcing 1 work for you? Or maybe something like
this:

diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c
index d8d934c..3209ccd 100644
--- a/hw/net/rocker/rocker_fp.c
+++ b/hw/net/rocker/rocker_fp.c
@@ -203,6 +203,7 @@ void fp_port_enable(FpPort *port)
     fp_port_set_link(port, true);
     port->enabled = true;
     DPRINTF("port %d enabled\n", port->index);
+    qemu_flush_queued_packets(qemu_get_queue(port->nic));
 }
 
 void fp_port_disable(FpPort *port)

---

Fam

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

* [Qemu-devel] (no subject)
@ 2015-06-30  4:49 Scott Feldman
  2015-06-30  7:18 ` Fam Zheng
  0 siblings, 1 reply; 133+ messages in thread
From: Scott Feldman @ 2015-06-30  4:49 UTC (permalink / raw)
  To: QEMU Developers, famz, Stefan Hajnoczi; +Cc: Jiří Pírko

Hi Fam, Stefan,

I'm running a test with rocker device using UDP sockets connections
and I'm seeing the socket s->read_poll stay disabled if the device
receives a packet when the device's can_receive returns false.
Receive is stuck after that; nothing ever re-enables s->read_poll.  I
see the first packet queued on queue->packets and that's it.   No more
receives.  If I modify the device to lie and always return
can_receive=true, and drop the pkt in driver receive, then things work
fine.

I think this patch broke can_receive semantics for net/socket.c:

commit 6e99c631f116221d169ea53953d91b8aa74d297a
Author: Fam Zheng <famz@redhat.com>
Date:   Thu Jun 4 14:45:16 2015 +0800

    net/socket: Drop net_socket_can_send

Anything jump out?

(In the test, rocker device is enabling the netdev port once the guest
OS driver signals to enable the port based on STP process running on
the guest.  The initial STP state is DISABLED, so the port is isolated
from the network.  As STP algo progresses, the port is opened up and
the netdev is enabled for Rx traffic).

-scott

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

* [Qemu-devel] (no subject)
@ 2015-05-03 14:10 yhindin
  0 siblings, 0 replies; 133+ messages in thread
From: yhindin @ 2015-05-03 14:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mdroth

Hi

    Recently, I've submitted patches to QEMU mailing list, introducing
creation of Windows MSI installation package for Windows QEMU Guest Agent,
but received not replies. Please, look into the suggested changes.

    The patches may be found in patchwork as
http://patchwork.ozlabs.org/patch/464618-464622

    Regards,
        Yossi Hindin
        

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

* [Qemu-devel] (no subject)
@ 2015-05-03 14:10 yhindin
  0 siblings, 0 replies; 133+ messages in thread
From: yhindin @ 2015-05-03 14:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mdroth

Hi

    Recently, I've submitted patches to QEMU mailing list, introducing
creation of Windows MSI installation package for Windows QEMU Guest Agent,
but received not replies. Please, look into the suggested changes.

    The patches may be found in patchwork as
http://patchwork.ozlabs.org/patch/464618-464622

    Regards,
        Yossi Hindin
        

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

* [Qemu-devel] (no subject)
@ 2015-05-03 14:10 yhindin
  0 siblings, 0 replies; 133+ messages in thread
From: yhindin @ 2015-05-03 14:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mdroth

Hi

    Recently, I've submitted patches to QEMU mailing list, introducing
creation of Windows MSI installation package for Windows QEMU Guest Agent,
but received not replies. Please, look into the suggested changes.

    The patches may be found in patchwork as
http://patchwork.ozlabs.org/patch/464618-464622

    Regards,
        Yossi Hindin
        

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

* [Qemu-devel] (no subject)
@ 2015-05-03 14:07 yhindin
  0 siblings, 0 replies; 133+ messages in thread
From: yhindin @ 2015-05-03 14:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mdroth

Hi

    Recently, I've submitted patches to QEMU mailing list, introducing
creation of Windows MSI installation package for Windows QEMU Guest Agent,
but received not replies. Please, look into the suggested changes.

    The patches may be found in patchwork as
http://patchwork.ozlabs.org/patch/464618-464622

    Regards,
        Yossi Hindin
        

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

* [Qemu-devel] (no subject)
@ 2015-05-03 14:07 yhindin
  0 siblings, 0 replies; 133+ messages in thread
From: yhindin @ 2015-05-03 14:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mdroth

Hi

    Recently, I've submitted patches to QEMU mailing list, introducing
creation of Windows MSI installation package for Windows QEMU Guest Agent,
but received not replies. Please, look into the suggested changes.

    The patches may be found in patchwork as
http://patchwork.ozlabs.org/patch/464618-464622

    Regards,
        Yossi Hindin
        

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

* [Qemu-devel] (no subject)
@ 2015-02-22  1:00 Sunil Kumar
  0 siblings, 0 replies; 133+ messages in thread
From: Sunil Kumar @ 2015-02-22  1:00 UTC (permalink / raw)
  To: qemu-devel

Hi,

I ran into an issue where the OVA created from the VMDK file created by qemu-img is rejected by vSphere with a message like "Not a supported disk format (sparse VMDK too old)". I was looking through the archives and found this:

http://lists.gnu.org/archive/html/qemu-devel/2014-08/msg01028.html

That's exactly my issue and the patch will resolve it. But this patch has not been merged yet and it does not apply on top of 2.2.0 cleanly. Any ideas what happened to the patch there?

I will appreciate any help.

-devsk 

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

* [Qemu-devel] (no subject)
@ 2014-12-06 10:54 Jun Li
  0 siblings, 0 replies; 133+ messages in thread
From: Jun Li @ 2014-12-06 10:54 UTC (permalink / raw)
  To: Max Reitz; +Cc: josh.durgin, juli, qemu-devel

stefanha@redhat.com
Bcc: 
Subject: Re: [Qemu-devel] qcow2: Can create qcow2 image format on rbd server
Reply-To: 
In-Reply-To: <5481E4E7.9010402@redhat.com>

On Fri, 12/05 18:01, Max Reitz wrote:
> On 2014-12-05 at 16:32, Jun Li wrote:
> >Currently, qemu-img can not create qcow2 image format on rbd server. Analysis
> >the code as followings:
> >when create qcow2 format image:
> >qcow2_create2
> >   bdrv_create_file(filename, opts, &local_err);  --> Here will create a 0 size
> >   file(e.g: file1) on rbd server.
> >   ...
> >   ret = bdrv_pwrite(bs, 0, header, cluster_size); --> So here can not write
> >   qcow2 header into file1 due to the file1's length is 0. Seems
> >   qemu_rbd_aio_writev can not write beyond EOF.
> >   ...
> >
> >As above analysis, there are two methods to solve the above bz as followings:
> >1, When create file1, just create a fixed-size file1 on rbd server(not 0 size).
> 
> Should be possible by using -o preallocation=falloc or -o
> preallocation=full.

Sure. If bdrv_create_file(filename, opts, &local_err) create a fixed-size(not
0 size) just as using "preallocation=falloc or preallocation=full", it will
create a fixed-size file on rbd server. So it won't exist above issue.

> 
> I can't say a lot about making rbd growable because I know near to nothing
> about rbd; but there are protocols which really simply don't support writes
> beyond the end of file, and where that's intended (for instance, while nbd
> somehow does support it when using the qemu nbd server, normally (strictly
> according to the protocol) it does not); so for these protocols, you have to
> use a preallocated image file or an image format which does not grow on
> writes (such as raw).
> 

Here just want to use rbd_resize to realize rbd growable.

> Of course, while that may be a solution for nbd, it doesn't sound like a
> good solution for rbd, so writes beyond the EOF should probably be supported
> there (although once again, I don't know rbd well enough to judge that).
> 

Yes, you are right. Also talked with stefan. Here just want to ask Josh Durgin
whether it has other solutions or rbd can support asynchronous rbd_resize.

Regards,
Jun Li

> 
> >2, When write the qcow2 header into file1, just let qemu_rbd_aio_writev can
> >enlarge the file1. So should add qemu_rbd_truncate inside qemu_rbd_aio_writev.
> >qemu_rbd_truncate will call rbd_resize, but seems rbd_resize is
> >synchronous function. If so, when do bdrv_pwrite, guest will hang.This is not
> >our expected.
> >
> >For method 1, maybe it's not corresponding to the original principle of qcow2.
> >Yes, it's very easy to solve the above bz. Nevertheless, I just want to use
> >method 2 to solve above issue.
> >
> >For method 2, could anyone give some suggestions on howto realize a
> >asynchronous rbd_resize. Thanks.
> >
> >Above analysis also based on stefan's hints. Thanks.
> >
> >Best Regards,
> >Jun Li
> 

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

* [Qemu-devel] (no subject)
@ 2014-11-10  3:14 xubin yan
  0 siblings, 0 replies; 133+ messages in thread
From: xubin yan @ 2014-11-10  3:14 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 6 bytes --]

hello

[-- Attachment #2: Type: text/html, Size: 27 bytes --]

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

* [Qemu-devel] (no subject)
@ 2014-09-17 16:20 Priyanka Ranjan
  0 siblings, 0 replies; 133+ messages in thread
From: Priyanka Ranjan @ 2014-09-17 16:20 UTC (permalink / raw)
  To: qemu-discuss; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

Hello Experts,
I am using CentOS 6.5. I am getting an issue with libguestfs (qemu-kvm)

 #  /usr/libexec/qemu-kvm -nographic -machine accel=kvm:tcg -device \?

 open /dev/kvm: No such file or directory
 failed to initialize KVM: Operation not permitted
 Back to tcg accelerator.
 Could not allocate dynamic translator buffer

I saw this issue listed in libguestfs faq  "
http://libguestfs.org/guestfs-faq.1.html"  and executed
 "setsebool -P virt_use_execmem=on"  as a solution but  that also did not
help. I confirmed this solution with libguestfs mailing list. They asked me
to to write to you. Could you please help me.

Thanks a lot in advance,

[-- Attachment #2: Type: text/html, Size: 2519 bytes --]

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

* [Qemu-devel] (no subject)
@ 2014-06-12 14:45 Puneet Bakshi
  0 siblings, 0 replies; 133+ messages in thread
From: Puneet Bakshi @ 2014-06-12 14:45 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

Hi,

I want to be able to install RPM packages (available in host system at some
path) to the online guest VM and want this facility to be available as a
tool.

I am thinking of having a gemu guest agent (qemu-ga) running inside guest
VM. I did not find any available command ("virsh qemu-agent-command
<guest_vm> ...") which can do the same.

I am planning to implement a command in qemu guest agent, which I can
invoke from virsh like below.

    "virsh qemu-agent-command vm_01          \
        '{"execute":"guest-rpm-
install",     \
          "arguments":{"path":"/usr/local/bin/ABC.rpm"}}

I am able to pass arguments from host to guest VM but how am I supposed to
pass the whole RPM image from host to guest (which the guest agent can
receive and install)?

Basically, I want to know how can we do following in QEMU environment.

    1. take some bulky file from host to guest
    2. perform some operation on that file
    3. get the result of that operation.

Regards,
~Puneet

[-- Attachment #2: Type: text/html, Size: 1470 bytes --]

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

* [Qemu-devel] (no subject)
@ 2014-02-04 14:18 Валентин Сайков
  0 siblings, 0 replies; 133+ messages in thread
From: Валентин Сайков @ 2014-02-04 14:18 UTC (permalink / raw)
  To: kvm; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

Good day. Very little speed drives Virtio. Drivers are the latest guest on
the system "Windows server 2008". Host system centos 6.5.

All that can be tried, but failed to increase the speed. And there I have a
database running.

Screenshots test speed drives

http://itmages.ru/image/view/1471772/feec35c3
http://itmages.ru/image/view/1471774/2b0baeae
http://itmages.ru/image/view/1471785/9fffb8f5

Thanks in advance. Apply nowhere else.

[-- Attachment #2: Type: text/html, Size: 798 bytes --]

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

* [Qemu-devel] (no subject)
  2013-11-21 19:33 ` [Qemu-devel] [PATCH for-1.7 2/5] acpi unit-test: adjust the test data structure for better handling Marcel Apfelbaum
@ 2013-12-10 16:42   ` Michael S. Tsirkin
  0 siblings, 0 replies; 133+ messages in thread
From: Michael S. Tsirkin @ 2013-12-10 16:42 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel

On Thu, Nov 21, 2013 at 09:33:22PM +0200, Marcel Apfelbaum wrote:
> Ensure more then one instance of test_data may exist
> at a given time. It will help to compare different
> acpi table versions.
> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>

Applied, thanks.

> ---
>  tests/acpi-test.c | 55 ++++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 32 insertions(+), 23 deletions(-)
> 
> diff --git a/tests/acpi-test.c b/tests/acpi-test.c
> index 43775cd..ca83b1d 100644
> --- a/tests/acpi-test.c
> +++ b/tests/acpi-test.c
> @@ -34,7 +34,7 @@ typedef struct {
>      uint32_t *rsdt_tables_addr;
>      int rsdt_tables_nr;
>      AcpiSdtTable dsdt_table;
> -    AcpiSdtTable *ssdt_tables;
> +    GArray *ssdt_tables;
>  } test_data;
>  
>  #define LOW(x) ((x) & 0xff)
> @@ -118,6 +118,18 @@ static uint8_t boot_sector[0x200] = {
>  
>  static const char *disk = "tests/acpi-test-disk.raw";
>  
> +static void free_test_data(test_data *data)
> +{
> +    int i;
> +
> +    g_free(data->rsdt_tables_addr);
> +    for (i = 0; i < data->ssdt_tables->len; ++i) {
> +        g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml);
> +    }
> +    g_array_free(data->ssdt_tables, false);
> +    g_free(data->dsdt_table.aml);
> +}
> +
>  static uint8_t acpi_checksum(const uint8_t *data, int len)
>  {
>      int i;
> @@ -295,30 +307,30 @@ static void test_acpi_dsdt_table(test_data *data)
>  
>  static void test_acpi_ssdt_tables(test_data *data)
>  {
> -    AcpiSdtTable *ssdt_tables;
> +    GArray *ssdt_tables;
>      int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
>      int i;
>  
> -    ssdt_tables = g_new0(AcpiSdtTable, ssdt_tables_nr);
> +    ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable),
> +                                    ssdt_tables_nr);
>      for (i = 0; i < ssdt_tables_nr; i++) {
> -        AcpiSdtTable *ssdt_table = &ssdt_tables[i];
> +        AcpiSdtTable ssdt_table;
>          uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
> -
> -        test_dst_table(ssdt_table, addr);
> +        test_dst_table(&ssdt_table, addr);
> +        g_array_append_val(ssdt_tables, ssdt_table);
>      }
>      data->ssdt_tables = ssdt_tables;
>  }
>  
> -static void test_acpi_one(const char *params)
> +static void test_acpi_one(const char *params, test_data *data)
>  {
>      char *args;
>      uint8_t signature_low;
>      uint8_t signature_high;
>      uint16_t signature;
>      int i;
> -    test_data data;
>  
> -    memset(&data, 0, sizeof(data));
> +    memset(data, 0, sizeof(*data));
>      args = g_strdup_printf("-net none -display none %s %s",
>                             params ? params : "", disk);
>      qtest_start(args);
> @@ -342,20 +354,13 @@ static void test_acpi_one(const char *params)
>      }
>      g_assert_cmphex(signature, ==, SIGNATURE);
>  
> -    test_acpi_rsdp_address(&data);
> -    test_acpi_rsdp_table(&data);
> -    test_acpi_rsdt_table(&data);
> -    test_acpi_fadt_table(&data);
> +    test_acpi_rsdp_address(data);
> +    test_acpi_rsdp_table(data);
> +    test_acpi_rsdt_table(data);
> +    test_acpi_fadt_table(data);
>      test_acpi_facs_table(data);
> -    test_acpi_dsdt_table(&data);
> -    test_acpi_ssdt_tables(&data);
> -
> -    g_free(data.rsdt_tables_addr);
> -    for (i = 0; i < (data.rsdt_tables_nr - 1); ++i) {
> -        g_free(data.ssdt_tables[i].aml);
> -    }
> -    g_free(data.ssdt_tables);
> -    g_free(data.dsdt_table.aml);
> +    test_acpi_dsdt_table(data);
> +    test_acpi_ssdt_tables(data);
>  
>      qtest_quit(global_qtest);
>      g_free(args);
> @@ -363,10 +368,14 @@ static void test_acpi_one(const char *params)
>  
>  static void test_acpi_tcg(void)
>  {
> +    test_data data;
> +
>      /* Supplying -machine accel argument overrides the default (qtest).
>       * This is to make guest actually run.
>       */
> -    test_acpi_one("-machine accel=tcg");
> +    test_acpi_one("-machine accel=tcg", &data);
> +
> +    free_test_data(&data);
>  }
>  
>  int main(int argc, char *argv[])
> -- 
> 1.8.3.1

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

* [Qemu-devel] (no subject)
@ 2013-08-18 18:19 Liu, Jinsong
  0 siblings, 0 replies; 133+ messages in thread
From: Liu, Jinsong @ 2013-08-18 18:19 UTC (permalink / raw)
  To: Gleb Natapov, Marcelo Tosatti, qemu-devel, kvm

[-- Attachment #1: Type: text/plain, Size: 2749 bytes --]

>From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Mon, 19 Aug 2013 09:33:30 +0800
Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL

This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623

IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
or kvm_get_msrs.

Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
 target-i386/kvm.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 84ac00a..7facbfe 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_star;
 static bool has_msr_hsave_pa;
 static bool has_msr_tsc_adjust;
 static bool has_msr_tsc_deadline;
+static bool has_msr_feature_control;
 static bool has_msr_async_pf_en;
 static bool has_msr_pv_eoi_en;
 static bool has_msr_misc_enable;
@@ -644,6 +645,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
 
     qemu_add_vm_change_state_handler(cpu_update_state, env);
 
+    c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
+    if (c)
+        has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) |
+                                  !!(c->ecx & CPUID_EXT_SMX);
+
     cpuid_data.cpuid.padding = 0;
     r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
     if (r) {
@@ -1121,7 +1127,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         if (hyperv_vapic_recommended()) {
             kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
         }
-        kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
+        if (has_msr_feature_control) {
+            kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
+                              env->msr_ia32_feature_control);
+        }
     }
     if (env->mcg_cap) {
         int i;
@@ -1346,7 +1355,9 @@ static int kvm_get_msrs(X86CPU *cpu)
     if (has_msr_misc_enable) {
         msrs[n++].index = MSR_IA32_MISC_ENABLE;
     }
-    msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+    if (has_msr_feature_control) {
+        msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+    }
 
     if (!env->tsc_valid) {
         msrs[n++].index = MSR_IA32_TSC;
@@ -1447,6 +1458,7 @@ static int kvm_get_msrs(X86CPU *cpu)
             break;
         case MSR_IA32_FEATURE_CONTROL:
             env->msr_ia32_feature_control = msrs[i].data;
+            break;
         default:
             if (msrs[i].index >= MSR_MC0_CTL &&
                 msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
-- 
1.7.1

[-- Attachment #2: 0001-qemu-kvm-bugfix-for-IA32_FEATURE_CONTROL.patch --]
[-- Type: application/octet-stream, Size: 2676 bytes --]

From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Mon, 19 Aug 2013 09:33:30 +0800
Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL

This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623

IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
or kvm_get_msrs.

Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
 target-i386/kvm.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 84ac00a..7facbfe 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_star;
 static bool has_msr_hsave_pa;
 static bool has_msr_tsc_adjust;
 static bool has_msr_tsc_deadline;
+static bool has_msr_feature_control;
 static bool has_msr_async_pf_en;
 static bool has_msr_pv_eoi_en;
 static bool has_msr_misc_enable;
@@ -644,6 +645,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
 
     qemu_add_vm_change_state_handler(cpu_update_state, env);
 
+    c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
+    if (c)
+        has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) |
+                                  !!(c->ecx & CPUID_EXT_SMX);
+
     cpuid_data.cpuid.padding = 0;
     r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
     if (r) {
@@ -1121,7 +1127,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         if (hyperv_vapic_recommended()) {
             kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
         }
-        kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
+        if (has_msr_feature_control) {
+            kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
+                              env->msr_ia32_feature_control);
+        }
     }
     if (env->mcg_cap) {
         int i;
@@ -1346,7 +1355,9 @@ static int kvm_get_msrs(X86CPU *cpu)
     if (has_msr_misc_enable) {
         msrs[n++].index = MSR_IA32_MISC_ENABLE;
     }
-    msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+    if (has_msr_feature_control) {
+        msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+    }
 
     if (!env->tsc_valid) {
         msrs[n++].index = MSR_IA32_TSC;
@@ -1447,6 +1458,7 @@ static int kvm_get_msrs(X86CPU *cpu)
             break;
         case MSR_IA32_FEATURE_CONTROL:
             env->msr_ia32_feature_control = msrs[i].data;
+            break;
         default:
             if (msrs[i].index >= MSR_MC0_CTL &&
                 msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
-- 
1.7.1


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

* [Qemu-devel] (no subject)
  2013-05-06 13:47 [Qemu-devel] [PATCH] Add 'maxqdepth' as an option to tty character devices Paolo Bonzini
@ 2013-05-07 16:36 ` John Baboval
  0 siblings, 0 replies; 133+ messages in thread
From: John Baboval @ 2013-05-07 16:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini

Thanks for the feedback. I've made the maxqdepth parameter optional as requested.

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

* Re: [Qemu-devel] (no subject)
  2013-04-02 16:02 Elizabeth Brown
@ 2013-04-05  7:18 ` Stefan Hajnoczi
  0 siblings, 0 replies; 133+ messages in thread
From: Stefan Hajnoczi @ 2013-04-05  7:18 UTC (permalink / raw)
  To: Elizabeth Brown; +Cc: qemu-devel

On Tue, Apr 02, 2013 at 12:02:52PM -0400, Elizabeth Brown wrote:
> I was wondering if anyone could help me by setting up a wiki account for me?

Done.

Stefan

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

* [Qemu-devel] (no subject)
@ 2013-04-02 16:02 Elizabeth Brown
  2013-04-05  7:18 ` Stefan Hajnoczi
  0 siblings, 1 reply; 133+ messages in thread
From: Elizabeth Brown @ 2013-04-02 16:02 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 136 bytes --]

I was wondering if anyone could help me by setting up a wiki account for me?

thank you very much for your assistance!

Elizabeth Brown

[-- Attachment #2: Type: text/html, Size: 223 bytes --]

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

* [Qemu-devel] (no subject)
@ 2012-11-19 20:39 Stefan Priebe
  0 siblings, 0 replies; 133+ messages in thread
From: Stefan Priebe @ 2012-11-19 20:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, ceph-devel, pve-devel

>From Stefan Priebe <s.priebe@profihost.ag> # This line is ignored.
From: Stefan Priebe <s.priebe@profihost.ag>
Cc: pve-devel@pve.proxmox.com
Cc: pbonzini@redhat.com
Cc: ceph-devel@vger.kernel.org
Subject: QEMU/PATCH: rbd block driver: fix race between completition and cancel
In-Reply-To:


ve-devel@pve.proxmox.com
pbonzini@redhat.com
ceph-devel@vger.kernel.org

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

* [Qemu-devel] (no subject)
@ 2012-07-23 10:59 Paulo Arcinas
  0 siblings, 0 replies; 133+ messages in thread
From: Paulo Arcinas @ 2012-07-23 10:59 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: Type: text/html, Size: 1 bytes --]

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

* [Qemu-devel] (no subject)
@ 2012-07-20  3:39 Guan Xuetao
  0 siblings, 0 replies; 133+ messages in thread
From: Guan Xuetao @ 2012-07-20  3:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, afaerber

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2800 bytes --]

are available in the git repository at:

  git://github.com/gxt/QEMU.git unicore32

Andreas Färber (1):
      target-unicore32: Drop UC32_CPUID macros

Guan Xuetao (13):
      unicore32-softmmu: Add unicore32-softmmu build support
      unicore32-softmmu: Add coprocessor 0(sysctrl) and 1(ocd) instruction support
      unicore32-softmmu: Make UniCore32 cpuid & exceptions correct and runable
      unicore32-softmmu: Implement softmmu specific functions
      unicore32-softmmu: Make sure that kernel can access user space
      unicore32-softmmu: Add puv3 soc/board support
      unicore32-softmmu: Add puv3 interrupt support
      unicore32-softmmu: Add puv3 ostimer support
      unicore32-softmmu: Add puv3 gpio support
      unicore32-softmmu: Add puv3 pm support
      unicore32-softmmu: Add puv3 dma support
      unicore32-softmmu: Add ps2 support
      unicore32-softmmu: Add maintainer information for UniCore32 machine

 MAINTAINERS                           |    8 +
 arch_init.c                           |    2 +
 arch_init.h                           |    1 +
 configure                             |    1 +
 cpu-exec.c                            |    1 +
 default-configs/unicore32-softmmu.mak |    4 +
 hw/Makefile.objs                      |    7 +
 hw/puv3.c                             |  130 ++++++++++++++++
 hw/puv3.h                             |   49 ++++++
 hw/puv3_dma.c                         |  109 +++++++++++++
 hw/puv3_gpio.c                        |  141 +++++++++++++++++
 hw/puv3_intc.c                        |  135 +++++++++++++++++
 hw/puv3_ost.c                         |  151 +++++++++++++++++++
 hw/puv3_pm.c                          |  149 ++++++++++++++++++
 hw/unicore32/Makefile.objs            |    6 +
 linux-user/main.c                     |    3 +-
 target-unicore32/Makefile.objs        |    2 +-
 target-unicore32/cpu.c                |   19 ++-
 target-unicore32/cpu.h                |   18 +--
 target-unicore32/helper.c             |  180 ++++++++++++++++++----
 target-unicore32/helper.h             |   17 +--
 target-unicore32/machine.c            |   23 +++
 target-unicore32/op_helper.c          |   44 ++++++-
 target-unicore32/softmmu.c            |  267 +++++++++++++++++++++++++++++++++
 target-unicore32/translate.c          |  116 +++++++++++++--
 25 files changed, 1509 insertions(+), 74 deletions(-)
 create mode 100644 default-configs/unicore32-softmmu.mak
 create mode 100644 hw/puv3.c
 create mode 100644 hw/puv3.h
 create mode 100644 hw/puv3_dma.c
 create mode 100644 hw/puv3_gpio.c
 create mode 100644 hw/puv3_intc.c
 create mode 100644 hw/puv3_ost.c
 create mode 100644 hw/puv3_pm.c
 create mode 100644 hw/unicore32/Makefile.objs
 create mode 100644 target-unicore32/machine.c
 create mode 100644 target-unicore32/softmmu.c

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

* [Qemu-devel] (no subject)
@ 2012-04-01 16:19 César
  0 siblings, 0 replies; 133+ messages in thread
From: César @ 2012-04-01 16:19 UTC (permalink / raw)
  To: qemu-devel

Hello there,

Consider I`ve an apllication A executing in "linux-user" mode. How can
I monitor the execution of some instructions from A? For example, all
calls. I thought inserting an interrupt before all calls and creating
a new interrupt handler could do the job, but I can´t get it working.
Any ideas on this?

César.

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

* [Qemu-devel] (no subject)
@ 2012-03-08  3:26 suyi wang
  0 siblings, 0 replies; 133+ messages in thread
From: suyi wang @ 2012-03-08  3:26 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 4880 bytes --]

Hi all:

I tried kvm on my ubuntu  with the libvirt.xml file as follows:
   <domain type='kvm'>
       <name>instance-00000011</
name>
       <memory>2097152</memory>
       <os>
               <type>hvm</type>
               <boot dev="hd" />
       </os>
       <features>
           <acpi/>
       </features>
       <vcpu>1</vcpu>
       <devices>
       <sound model='ac97'/>
       <input type='tablet' bus='usb'/>
           <disk type='file'>
               <driver type='qcow2'/>
               <source
   file='/opt/stack/nova/nova/../
/instances/instance-00000011/disk'/>
               <target dev='vda' bus='ide'/>
           </disk>
               <disk type='file'>
                   <driver type='qcow2'/>
                   <source

- Ignored:
   file='/opt/stack/nova/nova/..//instances/instance-00000011/disk.local'/>
                   <target dev='vdb' bus='ide'/>
               </disk>

           <interface type='bridge'>
               <source bridge='br100'/>
               <mac address='02:16:3e:44:a1:dd'/>
               <filterref
   filter="nova-instance-instance-00000011-02163e44a1dd">
                   <parameter name="IP" value="10.0.0.2" />
                   <parameter name="DHCPSERVER" value="10.0.0.1" />
               </filterref>
           </interface>

           <!-- The order is significant here.  File must be defined first
-->
           <serial type="file">
               <source
   path='/opt/stack/nova/nova/..//instances/instance-00000011/console.log'/>
               <target port='1'/>
           </serial>

           <console type='pty' tty='/dev/pts/2'>
               <source path='/dev/pts/2'/>
               <target port='0'/>
           </console>

           <serial type='pty'>
               <source path='/dev/pts/2'/>
               <target port='0'/>
           </serial>


           <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'
   listen='0.0.0.0'/>

       </devices>
   </domain>

   So it works well.

   Howerver, I want change the remote access method by spice, I simply
changed
   the libvirt.xml as follows:
   <domain type='kvm'>
       <name>instance-00000011</name>
       <memory>2097152</memory>
       <os>
               <type>hvm</type>
               <boot dev="hd" />
       </os>
       <features>
           <acpi/>
       </features>
       <vcpu>1</vcpu>
       <devices>
       <sound model='ac97'/>
       <input type='tablet' bus='usb'/>
           <disk type='file'>
               <driver type='qcow2'/>
               <source
   file='/opt/stack/nova/nova/..//instances/instance-00000011/disk'/>
               <target dev='vda' bus='ide'/>
           </disk>
               <disk type='file'>
                   <driver type='qcow2'/>
                   <source
   file='/opt/stack/nova/nova/..//instances/instance-00000011/disk.local'/>
                   <target dev='vdb' bus='ide'/>
               </disk>

           <interface type='bridge'>
               <source bridge='br100'/>
               <mac address='02:16:3e:44:a1:dd'/>
               <filterref
   filter="nova-instance-instance-00000011-02163e44a1dd">
                   <parameter name="IP" value="10.0.0.2" />
                   <parameter name="DHCPSERVER" value="10.0.0.1" />
               </filterref>
           </interface>

           <!-- The order is significant here.  File must be defined first
-->
           <serial type="file">
               <source
   path='/opt/stack/nova/nova/..//instances/instance-00000011/console.log'/>
               <target port='1'/>
           </serial>

           <console type='pty' tty='/dev/pts/2'>
               <source path='/dev/pts/2'/>
               <target port='0'/>
           </console>

           <serial type='pty'>
               <source path='/dev/pts/2'/>
               <target port='0'/>
           </serial>


           <graphics type='spice' port='-1' autoport='yes' keymap='en-us'
   listen='0.0.0.0'/>

       </devices>
   </domain>

   As you can see, I just change <graphics type='vnc' port='-1'
autoport='yes'
   keymap='en-us' listen='0.0.0.0'/> to <graphics type='spice' port='-1'
   autoport='yes' keymap='en-us' listen='0.0.0.0'/>   ,   But it called the
   error as follows:

   libvirtError: internal error Process exited while reading console log
   output: char device redirected to /dev/pts/12
   TRACE: do_spice_init: starting 0.8.1
   TRACE: do_spice_init: statistics shm_open failed, Permission denied"


Then I also  tried "ls -ld /dev/shm"   ,  yes, it is already  777.
then my problem remained:
libvirtError: internal error Process exited while reading console log
   output: char device redirected to /dev/pts/12
   TRACE: do_spice_init: starting 0.8.1
   TRACE: do_spice_init: statistics shm_open failed, Permission denied"


   I wish someone can give me some help! Thanks!


-- 
Yours.
suyi

[-- Attachment #2: Type: text/html, Size: 7176 bytes --]

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

* [Qemu-devel] (no subject)
       [not found] <[0/4] RESEND: Outstanding bugfixes and cleanups>
@ 2012-03-08  0:41 ` David Gibson
  0 siblings, 0 replies; 133+ messages in thread
From: David Gibson @ 2012-03-08  0:41 UTC (permalink / raw)
  To: anthony; +Cc: qemu-devel

These are patches that I've sent in before but don't seem to have been
picked up by anybody yet.  Resending so they don't fall off the radar.
1, 2, and 3 of 4 in particular fix real, observed bugs on powerpc.

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

* [Qemu-devel] (no subject)
@ 2012-02-29 12:43 Dmitry Fleytman
  0 siblings, 0 replies; 133+ messages in thread
From: Dmitry Fleytman @ 2012-02-29 12:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Alex Fishman, Michael S. Tsirkin, yvugenfi,
	Izik Eidus, Yan Vugenfirer, Dmitry Fleytman


>From ac51c01697ee2dc2ff2cb8c24346054ae0e3e32a Mon Sep 17 00:00:00 2001
From: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Date: Sun, 26 Feb 2012 18:39:07 +0200
Subject: [PATCH v2] VMXNET3 paravirtual NIC device implementation

Implementation of VMWare VMXNET3 paravirtual NIC device.
Supports of all the device features including offload capabilties,
VLANs and etc.
The device is tested on different OSes:
Fedora 15
Ubuntu 10.4
Centos 6.2
Windows 2008R2
Windows 2008 64bit
Windows 2008 32bit
Windows 2003 64bit
Windows 2003 32bit
Currently live migration is not supported.

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Yan Vugenfirer <yan@daynix.com>
---
 qemu/Makefile.objs           |    1 +
 qemu/default-configs/pci.mak |    1 +
 qemu/hw/pci.c                |    2 +
 qemu/hw/pci.h                |    1 +
 qemu/hw/virtio-net.h         |   13 +-
 qemu/hw/vmware_utils.h       |  131 +++
 qemu/hw/vmxnet3.c            | 2559 ++++++++++++++++++++++++++++++++++++++++++
 qemu/hw/vmxnet3.h            |  727 ++++++++++++
 qemu/hw/vmxnet3_debug.h      |  104 ++
 qemu/hw/vmxnet_utils.c       |  172 +++
 qemu/hw/vmxnet_utils.h       |  242 ++++
 qemu/net.c                   |    2 +-
 qemu/net/checksum.h          |    7 +
 13 files changed, 3955 insertions(+), 7 deletions(-)
 create mode 100644 qemu/hw/vmware_utils.h
 create mode 100644 qemu/hw/vmxnet3.c
 create mode 100644 qemu/hw/vmxnet3.h
 create mode 100644 qemu/hw/vmxnet3_debug.h
 create mode 100644 qemu/hw/vmxnet_utils.c
 create mode 100644 qemu/hw/vmxnet_utils.h

diff --git a/qemu/Makefile.objs b/qemu/Makefile.objs
index 808de6a..3f846a6 100644
--- a/qemu/Makefile.objs
+++ b/qemu/Makefile.objs
@@ -264,6 +264,7 @@ hw-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o
 hw-obj-$(CONFIG_PCNET_COMMON) += pcnet.o
 hw-obj-$(CONFIG_E1000_PCI) += e1000.o
 hw-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o
+hw-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o vmxnet_utils.o
 
 hw-obj-$(CONFIG_SMC91C111) += smc91c111.o
 hw-obj-$(CONFIG_LAN9118) += lan9118.o
diff --git a/qemu/default-configs/pci.mak b/qemu/default-configs/pci.mak
index 21e4ccf..f8e6ee1 100644
--- a/qemu/default-configs/pci.mak
+++ b/qemu/default-configs/pci.mak
@@ -13,6 +13,7 @@ CONFIG_PCNET_COMMON=y
 CONFIG_LSI_SCSI_PCI=y
 CONFIG_RTL8139_PCI=y
 CONFIG_E1000_PCI=y
+CONFIG_VMXNET3_PCI=y
 CONFIG_IDE_CORE=y
 CONFIG_IDE_QDEV=y
 CONFIG_IDE_PCI=y
diff --git a/qemu/hw/pci.c b/qemu/hw/pci.c
index bf046bf..f0fb1ee 100644
--- a/qemu/hw/pci.c
+++ b/qemu/hw/pci.c
@@ -1350,6 +1350,7 @@ static const char * const pci_nic_models[] = {
     "e1000",
     "pcnet",
     "virtio",
+    "vmxnet3",
     NULL
 };
 
@@ -1362,6 +1363,7 @@ static const char * const pci_nic_names[] = {
     "e1000",
     "pcnet",
     "virtio-net-pci",
+    "vmxnet3",
     NULL
 };
 
diff --git a/qemu/hw/pci.h b/qemu/hw/pci.h
index 4f19fdb..fee8250 100644
--- a/qemu/hw/pci.h
+++ b/qemu/hw/pci.h
@@ -60,6 +60,7 @@
 #define PCI_DEVICE_ID_VMWARE_NET         0x0720
 #define PCI_DEVICE_ID_VMWARE_SCSI        0x0730
 #define PCI_DEVICE_ID_VMWARE_IDE         0x1729
+#define PCI_DEVICE_ID_VMWARE_VMXNET3     0x07B0
 
 /* Intel (0x8086) */
 #define PCI_DEVICE_ID_INTEL_82551IT      0x1209
diff --git a/qemu/hw/virtio-net.h b/qemu/hw/virtio-net.h
index 4468741..fa3c17b 100644
--- a/qemu/hw/virtio-net.h
+++ b/qemu/hw/virtio-net.h
@@ -78,13 +78,14 @@ struct virtio_net_config
  * specify GSO or CSUM features, you can simply ignore the header. */
 struct virtio_net_hdr
 {
-#define VIRTIO_NET_HDR_F_NEEDS_CSUM     1       // Use csum_start, csum_offset
+#define VIRTIO_NET_HDR_F_NEEDS_CSUM     1     /* Use csum_start, csum_offset */
+#define VIRTIO_NET_HDR_F_DATA_VALID     2     /* Csum is valid               */
     uint8_t flags;
-#define VIRTIO_NET_HDR_GSO_NONE         0       // Not a GSO frame
-#define VIRTIO_NET_HDR_GSO_TCPV4        1       // GSO frame, IPv4 TCP (TSO)
-#define VIRTIO_NET_HDR_GSO_UDP          3       // GSO frame, IPv4 UDP (UFO)
-#define VIRTIO_NET_HDR_GSO_TCPV6        4       // GSO frame, IPv6 TCP
-#define VIRTIO_NET_HDR_GSO_ECN          0x80    // TCP has ECN set
+#define VIRTIO_NET_HDR_GSO_NONE         0     /* Not a GSO frame             */
+#define VIRTIO_NET_HDR_GSO_TCPV4        1     /* GSO frame, IPv4 TCP (TSO)   */
+#define VIRTIO_NET_HDR_GSO_UDP          3     /* GSO frame, IPv4 UDP (UFO)   */
+#define VIRTIO_NET_HDR_GSO_TCPV6        4     /* GSO frame, IPv6 TCP         */
+#define VIRTIO_NET_HDR_GSO_ECN          0x80  /* TCP has ECN set             */
     uint8_t gso_type;
     uint16_t hdr_len;
     uint16_t gso_size;
diff --git a/qemu/hw/vmware_utils.h b/qemu/hw/vmware_utils.h
new file mode 100644
index 0000000..304bb48
--- /dev/null
+++ b/qemu/hw/vmware_utils.h
@@ -0,0 +1,131 @@
+/*
+ * QEMU VMWARE paravirtual devices - auxiliary code
+ *
+ * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
+ *
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
+ *
+ * Authors:
+ * Dmitry Fleytman <dmitry@daynix.com>
+ * Yan Vugenfirer <yan@daynix.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+/* Shared memory access functions with byte swap support */
+static inline void
+vmw_shmem_read(target_phys_addr_t addr, void *buf, int len)
+{
+    DSHPRINTF("SHMEM r: %" PRIx64 ", len: %d to %p",
+              (uint64_t) addr, len, buf);
+    cpu_physical_memory_read(addr, buf, len);
+}
+
+static inline void
+vmw_shmem_write(target_phys_addr_t addr, void *buf, int len)
+{
+    DSHPRINTF("SHMEM w: %" PRIx64 ", len: %d to %p",
+              (uint64_t) addr, len, buf);
+    cpu_physical_memory_write(addr, buf, len);
+}
+
+static inline void
+vmw_shmem_rw(target_phys_addr_t addr, void *buf, int len, int is_write)
+{
+    DSHPRINTF("SHMEM r/w: %" PRIx64 ", len: %d (to %p), is write: %d",
+              (uint64_t) addr, len, buf, is_write);
+
+    cpu_physical_memory_rw(addr, buf, len, is_write);
+}
+
+static inline void
+vmw_shmem_set(target_phys_addr_t addr, uint8 val, int len)
+{
+    int i;
+    DSHPRINTF("SHMEM set: %" PRIx64 ", len: %d (value 0x%X)",
+              (uint64_t) addr, len, val);
+
+    for (i = 0; i < len; i++) {
+        cpu_physical_memory_write(addr + i, &val, 1);
+    }
+}
+
+static inline uint32_t
+vmw_shmem_ld8(target_phys_addr_t addr)
+{
+    uint8_t res = ldub_phys(addr);
+    DSHPRINTF("SHMEM load8: %" PRIx64 " (value 0x%X)",
+              (uint64_t) addr, res);
+    return res;
+}
+
+static inline void
+vmw_shmem_st8(target_phys_addr_t addr, uint8_t value)
+{
+    DSHPRINTF("SHMEM store8: %" PRIx64 " (value 0x%X)",
+              (uint64_t) addr, value);
+    stb_phys(addr, value);
+}
+
+static inline uint32_t
+vmw_shmem_ld16(target_phys_addr_t addr)
+{
+    uint16_t res = lduw_le_phys(addr);
+    DSHPRINTF("SHMEM load16: %" PRIx64 " (value 0x%X)",
+              (uint64_t) addr, res);
+    return res;
+}
+
+static inline void
+vmw_shmem_st16(target_phys_addr_t addr, uint16_t value)
+{
+    DSHPRINTF("SHMEM store16: %" PRIx64 " (value 0x%X)",
+              (uint64_t) addr, value);
+    stw_le_phys(addr, value);
+}
+
+static inline uint32_t
+vmw_shmem_ld32(target_phys_addr_t addr)
+{
+    uint32_t res = ldl_le_phys(addr);
+    DSHPRINTF("SHMEM load32: %" PRIx64 " (value 0x%X)",
+              (uint64_t) addr, res);
+    return res;
+}
+
+static inline void
+vmw_shmem_st32(target_phys_addr_t addr, uint32_t value)
+{
+    DSHPRINTF("SHMEM store32: %" PRIx64 " (value 0x%X)",
+              (uint64_t) addr, value);
+    stl_le_phys(addr, value);
+}
+
+static inline uint64_t
+vmw_shmem_ld64(target_phys_addr_t addr)
+{
+    uint64_t res = ldq_le_phys(addr);
+    DSHPRINTF("SHMEM load64: %" PRIx64 " (value %" PRIx64 ")",
+              (uint64_t) addr, res);
+    return res;
+}
+
+static inline void
+vmw_shmem_st64(target_phys_addr_t addr, uint64_t value)
+{
+    DSHPRINTF("SHMEM store64: %" PRIx64 " (value %" PRIx64 ")",
+              (uint64_t) addr, value);
+    stq_le_phys(addr, value);
+}
+
+/* MACROS for simplification of operations on array-style registers */
+#define IS_MULTIREG_ADDR(addr, base, cnt, regsize)                 \
+    (((addr) >= (base)) && ((addr) < (base) + (cnt) * (regsize)))
+
+#define MULTIREG_IDX_BY_ADDR(addr, base, regsize)                  \
+    (((addr) - (base)) / (regsize))
+
+/* Bitfields */
+#define FLAG_IS_SET(field, flag) (((field) & (flag)) == (flag))
diff --git a/qemu/hw/vmxnet3.c b/qemu/hw/vmxnet3.c
new file mode 100644
index 0000000..112d3b9
--- /dev/null
+++ b/qemu/hw/vmxnet3.c
@@ -0,0 +1,2559 @@
+/*
+ * QEMU VMWARE VMXNET3 paravirtual NIC
+ *
+ * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
+ *
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
+ *
+ * Authors:
+ * Dmitry Fleytman <dmitry@daynix.com>
+ * Yan Vugenfirer <yan@daynix.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#define VMXNET3_ENABLE_MSIX
+#define VMXNET3_ENABLE_MSI
+
+/* Define this constant to non-zero to enable IP4       */
+/* fragmentation feature                                */
+
+/* #define VMXNET_MAX_IP_PLOAD_LEN ETH_MAX_IP_PLOAD_LEN */
+#define VMXNET3_MAX_IP_PLOAD_LEN 0
+
+#include "hw.h"
+#include "pci.h"
+#include "net.h"
+#include "virtio-net.h"
+#include "net/tap.h"
+#include "sysemu.h"
+#include "iov.h"
+#include "bswap.h"
+#ifdef VMXNET3_ENABLE_MSIX
+#include "msix.h"
+#endif
+#ifdef VMXNET3_ENABLE_MSI
+#include "msi.h"
+#endif
+
+#include "vmxnet3_debug.h"
+#include "vmxnet3.h"
+#include "vmware_utils.h"
+#include "vmxnet_utils.h"
+
+#define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1
+#define VMXNET3_MSIX_BAR_SIZE 0x2000
+
+#define VMXNET3_BAR0_IDX      (0)
+#define VMXNET3_BAR1_IDX      (1)
+#define VMXNET3_MSIX_BAR_IDX  (2)
+
+/* Link speed in Mbps should be shifted by 16 */
+#define VMXNET3_LINK_SPEED      (1000 << 16)
+
+/* Link status: 1 - up, 0 - down. */
+#define VMXNET3_LINK_STATUS_UP  0x1
+
+/* Least significant bit should be set for revision and version */
+#define VMXNET3_DEVICE_VERSION    0x1
+#define VMXNET3_DEVICE_REVISION   0x1
+
+/* Macros for rings descriptors access */
+#define VMXNET3_READ_TX_QUEUE_DESCR8(dpa, field) \
+    (vmw_shmem_ld8(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field)))
+
+#define VMXNET3_WRITE_TX_QUEUE_DESCR8(dpa, field, value) \
+    (vmw_shmem_st8(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field, value)))
+
+#define VMXNET3_READ_TX_QUEUE_DESCR32(dpa, field) \
+    (vmw_shmem_ld32(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field)))
+
+#define VMXNET3_WRITE_TX_QUEUE_DESCR32(dpa, field, value) \
+    (vmw_shmem_st32(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field), value))
+
+#define VMXNET3_READ_TX_QUEUE_DESCR64(dpa, field) \
+    (vmw_shmem_ld64(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field)))
+
+#define VMXNET3_WRITE_TX_QUEUE_DESCR64(dpa, field, value) \
+    (vmw_shmem_st64(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field), value))
+
+#define VMXNET3_READ_RX_QUEUE_DESCR64(dpa, field) \
+    (vmw_shmem_ld64(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field)))
+
+#define VMXNET3_READ_RX_QUEUE_DESCR32(dpa, field) \
+    (vmw_shmem_ld32(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field)))
+
+#define VMXNET3_WRITE_RX_QUEUE_DESCR64(dpa, field, value) \
+    (vmw_shmem_st64(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field), value))
+
+#define VMXNET3_WRITE_RX_QUEUE_DESCR8(dpa, field, value) \
+    (vmw_shmem_st8(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field), value))
+
+/* Macros for guest driver shared area access */
+#define VMXNET3_READ_DRV_SHARED64(shpa, field) \
+    (vmw_shmem_ld64(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
+
+#define VMXNET3_READ_DRV_SHARED32(shpa, field) \
+    (vmw_shmem_ld32(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
+
+#define VMXNET3_WRITE_DRV_SHARED32(shpa, field, val) \
+    (vmw_shmem_st32(shpa + offsetof(struct Vmxnet3_DriverShared, field), val))
+
+#define VMXNET3_READ_DRV_SHARED16(shpa, field) \
+    (vmw_shmem_ld16(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
+
+#define VMXNET3_READ_DRV_SHARED8(shpa, field) \
+    (vmw_shmem_ld8(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
+
+#define VMXNET3_READ_DRV_SHARED(shpa, field, b, l) \
+    (vmw_shmem_read(shpa + offsetof(struct Vmxnet3_DriverShared, field), b, l))
+
+/* TX/RX packets abstractions */
+typedef struct Vmxnet3_TxPktMdata {
+    uint32_t offload_mode;
+    uint32_t cso_or_gso_size;
+    uint32_t hdr_length;
+    eth_pkt_types_e packet_type;
+} Vmxnet3_TxPktMdata;
+
+typedef struct _Vmxnet3_RxPktMdata {
+    uint32_t tot_len;
+    uint16_t vlan_tag;
+    bool vlan_stripped;
+    bool vhdr_valid;
+    eth_pkt_types_e packet_type;
+} Vmxnet3_RxPktMdata;
+
+#define VMXNET3_TXPKT_REBUILT_HDR_LEN (1024)
+
+typedef struct _Vmxnet3_TxPkt {
+    Vmxnet3_TxPktMdata mdata;
+    struct virtio_net_hdr virt_hdr;
+    bool has_virt_hdr;
+
+    struct iovec *vec;
+
+    uint8_t __l2_hdr[ETH_MAX_L2_HDR_LEN];
+    uint8_t __l3_hdr[ETH_MAX_L3_HDR_LEN];
+
+    uint32_t payload_len;
+    uint32_t max_payload_len;
+
+    uint32_t payload_frags;
+    uint32_t max_payload_frags;
+
+    struct {
+        uint32_t offset;
+        bool more_frags;
+        bool orig_more_frags;
+    } fragmentation;
+} Vmxnet3_TxPkt;
+
+#define VMXNET3_TXPKT_VHDR_FRAG     (0)
+#define VMXNET3_TXPKT_L2HDR_FRAG    (1)
+#define VMXNET3_TXPKT_L3HDR_FRAG    (2)
+#define VMXNET3_TXPKT_PL_START_FRAG (3)
+
+#define vmxnet3_txpkt_get_mdata(p) (&((p)->mdata))
+#define vmxnet3_txpkt_get_vhdr(p) (&((p)->virt_hdr))
+
+#define vmxnet3_txpkt_get_l2hdr(p)         \
+    ((p)->vec[VMXNET3_TXPKT_L2HDR_FRAG].iov_base)
+#define vmxnet3_txpkt_get_l2hdr_len(p)     \
+    ((p)->vec[VMXNET3_TXPKT_L2HDR_FRAG].iov_len)
+#define vmxnet3_txpkt_set_l2hdr_len(p, l)  \
+    ((p)->vec[VMXNET3_TXPKT_L2HDR_FRAG].iov_len = l)
+#define vmxnet3_txpkt_get_l3hdr(p)         \
+    ((p)->vec[VMXNET3_TXPKT_L3HDR_FRAG].iov_base)
+#define vmxnet3_txpkt_get_l3hdr_len(p)     \
+    ((p)->vec[VMXNET3_TXPKT_L3HDR_FRAG].iov_len)
+#define vmxnet3_txpkt_set_l3hdr_len(p, l)  \
+    ((p)->vec[VMXNET3_TXPKT_L3HDR_FRAG].iov_len = l)
+#define vmxnet3_txpkt_get_payload_len(p)   \
+    ((p)->payload_len)
+
+#define vmxnet3_txpkt_set_more_frags(p, mf)    \
+    ((p)->fragmentation.more_frags = mf)
+#define vmxnet3_txpkt_get_more_frags(p)        \
+    ((p)->fragmentation.more_frags | \
+    (p)->fragmentation.orig_more_frags)
+#define vmxnet3_txpkt_set_frag_off(p, off)     \
+    ((p)->fragmentation.offset = off)
+#define vmxnet3_txpkt_get_frag_off(p)          \
+    ((p)->fragmentation.offset)
+#define vmxnet3_txpkt_advance_frag_off(p, off) \
+    ((p)->fragmentation.offset += off)
+
+static inline size_t
+vmxnet3_txpkt_get_total_len(const Vmxnet3_TxPkt *p)
+{
+    return vmxnet3_txpkt_get_l2hdr_len(p) +
+           vmxnet3_txpkt_get_l3hdr_len(p) +
+           vmxnet3_txpkt_get_payload_len(p);
+}
+
+static inline struct iovec*
+vmxnet3_txpkt_get_payload_frag(Vmxnet3_TxPkt *p, uint32_t num)
+{
+    assert(num < p->max_payload_frags);
+    return &p->vec[num + VMXNET3_TXPKT_PL_START_FRAG];
+}
+
+static inline void
+vmxnet3_txpkt_set_num_pl_frags(Vmxnet3_TxPkt *p, uint32_t num)
+{
+     assert(num <= p->max_payload_frags);
+     p->payload_frags = num;
+}
+
+static inline void
+vmxnet3_txpkt_reset_payload(Vmxnet3_TxPkt *p)
+{
+    p->payload_len = 0;
+}
+
+static void vmxnet3_txpkt_reset(Vmxnet3_TxPkt *p)
+{
+    memset(&p->mdata, 0, sizeof(p->mdata));
+    vmxnet3_txpkt_set_num_pl_frags(p, 0);
+    vmxnet3_txpkt_reset_payload(p);
+    vmxnet3_txpkt_set_more_frags(p, 0);
+    vmxnet3_txpkt_set_frag_off(p, 0);
+    p->max_payload_len = 0;
+
+    if (NULL != p->vec) {
+        p->vec[VMXNET3_TXPKT_L2HDR_FRAG].iov_len = 0;
+        p->vec[VMXNET3_TXPKT_L3HDR_FRAG].iov_len = 0;
+    }
+}
+
+static bool
+vmxnet3_txpkt_prealloc(Vmxnet3_TxPkt *p, uint32_t max_frags, bool has_virt_hdr)
+{
+    if (NULL != p->vec) {
+        g_free(p->vec);
+    }
+
+    p->vec =
+        g_malloc(sizeof(*p->vec) * (max_frags + VMXNET3_TXPKT_PL_START_FRAG));
+    if (NULL == p->vec) {
+        return false;
+    }
+
+    p->max_payload_frags = max_frags;
+    p->has_virt_hdr = has_virt_hdr;
+    p->vec[VMXNET3_TXPKT_VHDR_FRAG].iov_base = &p->virt_hdr;
+    p->vec[VMXNET3_TXPKT_VHDR_FRAG].iov_len =
+        p->has_virt_hdr ? sizeof(p->virt_hdr) : 0;
+    p->vec[VMXNET3_TXPKT_L2HDR_FRAG].iov_base = &p->__l2_hdr;
+    p->vec[VMXNET3_TXPKT_L3HDR_FRAG].iov_base = &p->__l3_hdr;
+    vmxnet3_txpkt_reset(p);
+    return true;
+}
+
+static void vmxnet3_txpkt_init(Vmxnet3_TxPkt *p)
+{
+    p->vec = NULL;
+}
+
+static void vmxnet3_txpkt_cleanup(Vmxnet3_TxPkt *p)
+{
+    g_free(p->vec);
+}
+
+static void vmxnet3_txpkt_unmap(Vmxnet3_TxPkt *p, bool is_write)
+{
+    int i;
+
+    for (i = VMXNET3_TXPKT_PL_START_FRAG;
+        i < p->payload_frags + VMXNET3_TXPKT_PL_START_FRAG; i++) {
+        cpu_physical_memory_unmap(p->vec[i].iov_base, p->vec[i].iov_len,
+                                  is_write, p->vec[i].iov_len);
+    }
+}
+
+static void*
+vmxnet3_txpkt_map(Vmxnet3_TxPkt *p, uint32_t *mapped_fragments, bool is_write)
+{
+    int i;
+
+    for (i = VMXNET3_TXPKT_PL_START_FRAG;
+        i < p->payload_frags + VMXNET3_TXPKT_PL_START_FRAG; i++) {
+        target_phys_addr_t mapped_len = p->vec[i].iov_len;
+        size_t orig_len = p->vec[i].iov_len;
+        p->vec[i].iov_base =
+            cpu_physical_memory_map((uint64_t) p->vec[i].iov_base,
+                                    &mapped_len, is_write);
+        p->vec[i].iov_len = mapped_len;
+
+        if ((NULL == p->vec[i].iov_base) || (orig_len != mapped_len)) {
+            p->payload_frags = i + !!p->vec[i].iov_base;
+            vmxnet3_txpkt_unmap(p, is_write);
+            return NULL;
+        }
+    }
+
+    *mapped_fragments = VMXNET3_TXPKT_PL_START_FRAG + p->payload_frags;
+    return p->vec;
+}
+
+static inline void
+vmxnet3_txpkt_dump(Vmxnet3_TxPkt *p)
+{
+#ifdef DEBUG_VMXNET3_PACKETS
+    Vmxnet3_TxPktMdata *m = vmxnet3_txpkt_get_mdata(p);
+#endif
+
+    DPKPRINTF("TXPKT MDATA: om: %d, cso/gso_size: %d, hdr_len: %d, "
+              "pkt_type: 0x%X, l2hdr_len: %lu l3hdr_len: %lu, payload_len: %u",
+              m->offload_mode, m->cso_or_gso_size,
+              m->hdr_length, m->packet_type,
+              vmxnet3_txpkt_get_l2hdr_len(p),
+              vmxnet3_txpkt_get_l3hdr_len(p),
+              vmxnet3_txpkt_get_payload_len(p));
+};
+
+/* RX packet may contain up to 2 fragments - rebuilt eth header */
+/* in case of VLAN tag stripping                                */
+/* and payload received from QEMU - in any case                 */
+#define VMXNET3_MAX_RX_PACKET_FRAGMENTS (2)
+
+typedef struct _Vmxnet3_RxPkt {
+    Vmxnet3_RxPktMdata mdata;
+    struct virtio_net_hdr virt_hdr;
+    struct eth_header eth_hdr;
+    struct iovec vec[VMXNET3_MAX_RX_PACKET_FRAGMENTS];
+    uint16 vec_len;
+} Vmxnet3_RxPkt;
+
+#define vmxnet3_rxpkt_get_mdata(p)          (&((p)->mdata))
+#define vmxnet3_rxpkt_get_ehdr(p)           (&((p)->eth_hdr))
+#define vmxnet3_rxpkt_get_vhdr(p)           (&((p)->virt_hdr))
+#define vmxnet3_rxpkt_get_frag(p, n)        (&((p)->vec[(n)]))
+#define vmxnet3_rxpkt_set_num_frags(p, n)   ((p)->vec_len = (n))
+#define vmxnet3_rxpkt_get_num_frags(p)      ((p)->vec_len)
+
+static inline void vmxnet3_rxpkt_attach_ehdr(Vmxnet3_RxPkt *p)
+{
+    vmxnet3_rxpkt_get_frag(p, 0)->iov_base = &p->eth_hdr;
+    vmxnet3_rxpkt_get_frag(p, 0)->iov_len = sizeof(p->eth_hdr);
+}
+
+static inline void vmxnet3_rxpkt_reset(Vmxnet3_RxPkt *p)
+{
+    memset(&p->mdata, 0, sizeof(p->mdata));
+    memset(&p->virt_hdr, 0, sizeof(p->virt_hdr));
+    vmxnet3_rxpkt_set_num_frags(p, 0);
+}
+
+static void vmxnet3_rxpkt_init(Vmxnet3_RxPkt *p)
+{
+    vmxnet3_rxpkt_reset(p);
+}
+
+static inline void
+vmxnet3_rxpkt_dump(Vmxnet3_RxPkt *p)
+{
+#ifdef DEBUG_VMXNET3_PACKETS
+    Vmxnet3_RxPktMdata *m = vmxnet3_rxpkt_get_mdata(p);
+#endif
+
+    DPKPRINTF("RXPKT MDATA: tot_len: %d, pkt_type: 0x%X, "
+              "vlan_stripped: %d, vlan_tag: %d, vhdr_valid: %d",
+              m->tot_len, m->packet_type,
+              m->vlan_stripped, m->vlan_tag, m->vhdr_valid);
+};
+
+/* Cyclic ring abstraction */
+typedef struct _Vmxnet3_Ring {
+    target_phys_addr_t pa;
+    size_t size;
+    size_t cell_size;
+    size_t next;
+    uint8_t gen;
+} Vmxnet3_Ring;
+
+static inline void vmxnet3_ring_init(Vmxnet3_Ring *ring,
+                                     target_phys_addr_t pa,
+                                     size_t size,
+                                     size_t cell_size,
+                                     bool zero_region)
+{
+    ring->pa = pa;
+    ring->size = size;
+    ring->cell_size = cell_size;
+    ring->gen = VMXNET3_INIT_GEN;
+    ring->next = 0;
+
+    if (zero_region) {
+        vmw_shmem_set(pa, 0, size*cell_size);
+    }
+}
+
+#define vmxnet3_ring_dump(macro, ring_name, ridx, r)                         \
+    macro("%s#%d: base %" PRIx64 " size %lu cell_size %lu gen %d next %lu",  \
+          (ring_name), (ridx), (uint64_t) (r)->pa,                           \
+          (r)->size, (r)->cell_size, (r)->gen, (r)->next)
+
+static inline void vmxnet3_ring_inc(Vmxnet3_Ring *ring)
+{
+    if (++ring->next >= ring->size) {
+        ring->next = 0;
+        ring->gen ^= 1;
+    }
+}
+
+static inline void vmxnet3_ring_dec(Vmxnet3_Ring *ring)
+{
+    if (0 == ring->next--) {
+        ring->next = ring->size - 1;
+        ring->gen ^= 1;
+    }
+}
+
+static inline target_phys_addr_t vmxnet3_ring_curr_cell_pa(Vmxnet3_Ring *ring)
+{
+    return ring->pa + ring->next * ring->cell_size;
+}
+
+static inline void vmxnet3_ring_read_curr_cell(Vmxnet3_Ring *ring, void *buff)
+{
+    vmw_shmem_read(vmxnet3_ring_curr_cell_pa(ring), buff, ring->cell_size);
+}
+
+static inline void vmxnet3_ring_write_curr_cell(Vmxnet3_Ring *ring, void *buff)
+{
+    vmw_shmem_write(vmxnet3_ring_curr_cell_pa(ring), buff, ring->cell_size);
+}
+
+static inline size_t vmxnet3_ring_curr_cell_idx(Vmxnet3_Ring *ring)
+{
+    return ring->next;
+}
+
+static inline uint8_t vmxnet3_ring_curr_gen(Vmxnet3_Ring *ring)
+{
+    return ring->gen;
+}
+
+/* Debug trace-related functions */
+static inline void
+vmxnet3_dump_tx_descr(struct Vmxnet3_TxDesc *descr)
+{
+    DPKPRINTF("TX DESCR: "
+              "addr %" PRIx64 ", len: %d, gen: %d, rsvd: %d, "
+              "dtype: %d, ext1: %d, msscof: %d, hlen: %d, om: %d, "
+              "eop: %d, cq: %d, ext2: %d, ti: %d, tci: %d",
+              le64_to_cpu(descr->addr), descr->len, descr->gen, descr->rsvd,
+              descr->dtype, descr->ext1, descr->msscof, descr->hlen, descr->om,
+              descr->eop, descr->cq, descr->ext2, descr->ti, descr->tci);
+}
+
+static inline void
+vmxnet3_dump_virt_hdr(struct virtio_net_hdr *vhdr)
+{
+    DPKPRINTF("VHDR: flags 0x%x, gso_type: 0x%x, hdr_len: %d, gso_size: %d, "
+              "csum_start: %d, csum_offset: %d",
+              vhdr->flags, vhdr->gso_type, vhdr->hdr_len, vhdr->gso_size,
+              vhdr->csum_start, vhdr->csum_offset);
+}
+
+static inline void
+vmxnet3_dump_rx_descr(struct Vmxnet3_RxDesc *descr)
+{
+    DPKPRINTF("RX DESCR: addr %" PRIx64 ", len: %d, gen: %d, rsvd: %d, "
+              "dtype: %d, ext1: %d, btype: %d",
+              le64_to_cpu(descr->addr), descr->len, descr->gen,
+              descr->rsvd, descr->dtype, descr->ext1, descr->btype);
+}
+
+/* Device state and helper functions */
+#define VMXNET3_RX_RINGS_PER_QUEUE (2)
+
+typedef struct _VMXNET3_State {
+        PCIDevice dev;
+        NICState *nic;
+        NICConf conf;
+        MemoryRegion bar0;
+        MemoryRegion bar1;
+        MemoryRegion msix_bar;
+
+#ifdef VMXNET3_ENABLE_MSIX
+        /* Whether MSI-X support was installed successfully */
+        uint8_t msix_used;
+#endif
+#ifdef VMXNET3_ENABLE_MSI
+        /* Whether MSI support was installed successfully */
+        uint8_t msi_used;
+#endif
+
+        target_phys_addr_t drv_shmem;
+        target_phys_addr_t temp_shared_guest_driver_memory;
+
+        uint8_t txq_num;
+        struct {
+            Vmxnet3_Ring tx_ring;
+            Vmxnet3_Ring comp_ring;
+
+            uint8_t intr_idx;
+            target_phys_addr_t tx_stats_pa;
+            struct UPT1_TxStats txq_stats;
+        } txq_descr[VMXNET3_DEVICE_MAX_TX_QUEUES];
+
+        /* This boolean tells whether RX packet being indicated has to */
+        /* be split into head and body chunks from different RX rings  */
+        bool rx_packets_compound;
+
+        bool rx_vlan_stripping;
+        bool lro_supported;
+
+        uint8_t rxq_num;
+        struct {
+            Vmxnet3_Ring rx_ring[VMXNET3_RX_RINGS_PER_QUEUE];
+            Vmxnet3_Ring comp_ring;
+            uint8_t intr_idx;
+            target_phys_addr_t rx_stats_pa;
+            struct UPT1_RxStats rxq_stats;
+        } rxq_descr[VMXNET3_DEVICE_MAX_RX_QUEUES];
+
+        /* Network MTU */
+        uint32_t mtu;
+
+        /* Maximum number of fragments for indicated TX packets */
+        uint32_t max_tx_frags;
+
+        /* Maximum number of fragments for indicated RX packets */
+        uint16_t max_rx_frags;
+
+        /* Index for events interrupt */
+        uint8_t event_int_idx;
+
+        /* Whether automatic interrupts masking enabled */
+        uint8_t auto_int_masking;
+
+        bool peer_has_vhdr;
+
+        /* TX packets to QEMU interface */
+        Vmxnet3_TxPkt curr_txpkt;
+        size_t curr_txpkt_pl_frags;
+        bool curr_txpkt_skip;
+        bool curr_txpkt_header_processed;
+
+        uint32_t device_active;
+        uint32_t last_command;
+
+        uint32_t link_status_and_speed;
+
+        struct {
+            bool is_masked;
+            bool is_pending;
+            bool is_asserted;
+        } interrupt_states[VMXNET3_MAX_INTRS];
+
+        uint32_t temp_mac;   /* To store the low part first */
+
+        MACAddr perm_mac;
+        uint32_t vlan_table[VMXNET3_VFT_SIZE];
+        uint32_t rx_mode;
+        MACAddr *mcast_list;
+        uint16_t mcast_list_len;
+} VMXNET3_State;
+
+/* Interrupt management */
+
+/* This function returns sign whether interrupt line is in asserted state   */
+/* This depends on the type of interrupt used. For INTX interrupt line will */
+/* be asserted until explicit deassertion, for MSI(X) interrupt line will   */
+/* be deasserted automatically due to notifiction symantics of the MSI(X)   */
+/* interrupts                                                               */
+static bool _vmxnet3_assert_interrupt_line(VMXNET3_State *s, uint32_t int_idx)
+{
+#ifdef VMXNET3_ENABLE_MSIX
+    if (s->msix_used && msix_enabled(&s->dev)) {
+        DIRPRINTF("Sending MSI-X notification for vector %u", int_idx);
+        msix_notify(&s->dev, int_idx);
+        return false;
+    }
+#endif
+#ifdef VMXNET3_ENABLE_MSI
+    if (s->msi_used && msi_enabled(&s->dev)) {
+        DIRPRINTF("Sending MSI notification for vector %u", int_idx);
+        msi_notify(&s->dev, int_idx);
+        return false;
+    }
+#endif
+
+    DIRPRINTF("Asserting line for interrupt %u", int_idx);
+    qemu_set_irq(s->dev.irq[int_idx], 1);
+    return true;
+}
+
+static void _vmxnet3_deassert_interrupt_line(VMXNET3_State *s, int lidx)
+{
+#ifdef VMXNET3_ENABLE_MSIX
+    /* This function should never be called for MSI(X) interrupts */
+    /* because deassertion never required for message interrupts  */
+    assert(!s->msix_used || !msix_enabled(&s->dev));
+#endif
+#ifdef VMXNET3_ENABLE_MSI
+    /* This function should never be called for MSI(X) interrupts */
+    /* because deassertion never required for message interrupts  */
+    assert(!s->msi_used || !msi_enabled(&s->dev));
+#endif
+
+    DIRPRINTF("Deasserting line for interrupt %u", lidx);
+    qemu_set_irq(s->dev.irq[lidx], 0);
+}
+
+static void vmxnet3_update_interrupt_line_state(VMXNET3_State *s, int lidx)
+{
+    if (!s->interrupt_states[lidx].is_pending &&
+       s->interrupt_states[lidx].is_asserted) {
+        DIRPRINTF("New interrupt line state for index %d is DOWN", lidx);
+        _vmxnet3_deassert_interrupt_line(s, lidx);
+        s->interrupt_states[lidx].is_asserted = false;
+        return;
+    }
+
+    if (s->interrupt_states[lidx].is_pending &&
+       !s->interrupt_states[lidx].is_masked &&
+       !s->interrupt_states[lidx].is_asserted) {
+        DIRPRINTF("New interrupt line state for index %d is UP", lidx);
+        s->interrupt_states[lidx].is_asserted =
+            _vmxnet3_assert_interrupt_line(s, lidx);
+        s->interrupt_states[lidx].is_pending = false;
+        return;
+    }
+}
+
+static void vmxnet3_trigger_interrupt(VMXNET3_State *s, int lidx)
+{
+    s->interrupt_states[lidx].is_pending = true;
+    vmxnet3_update_interrupt_line_state(s, lidx);
+
+#ifdef VMXNET3_ENABLE_MSIX
+    if (s->msix_used && msix_enabled(&s->dev) && s->auto_int_masking) {
+        goto do_automask;
+    }
+#endif
+
+#ifdef VMXNET3_ENABLE_MSI
+    if (s->msi_used && msi_enabled(&s->dev) && s->auto_int_masking) {
+        goto do_automask;
+    }
+#endif
+
+    return;
+
+do_automask:
+    s->interrupt_states[lidx].is_masked = true;
+    vmxnet3_update_interrupt_line_state(s, lidx);
+}
+
+static bool vmxnet3_interrupt_asserted(VMXNET3_State *s, int lidx)
+{
+    return s->interrupt_states[lidx].is_asserted;
+}
+
+static void vmxnet3_clear_interrupt(VMXNET3_State *s, int int_idx)
+{
+    s->interrupt_states[int_idx].is_pending = false;
+    if (s->auto_int_masking) {
+        s->interrupt_states[int_idx].is_masked = true;
+    }
+    vmxnet3_update_interrupt_line_state(s, int_idx);
+}
+
+static void
+vmxnet3_on_interrupt_mask_changed(VMXNET3_State *s, int lidx, bool is_masked)
+{
+    s->interrupt_states[lidx].is_masked = is_masked;
+    vmxnet3_update_interrupt_line_state(s, lidx);
+}
+
+static bool vmxnet3_verify_driver_magic(target_phys_addr_t dshmem)
+{
+    return (VMXNET3_REV1_MAGIC == VMXNET3_READ_DRV_SHARED32(dshmem, magic));
+}
+
+#define _GET_BYTE(x, byte_num) (((x) >> (byte_num)*8) & 0xFF)
+#define _MAKE_BYTE(byte_num, val) (((uint32_t)((val) & 0xFF)) << (byte_num)*8)
+
+static void vmxnet3_set_variable_mac(VMXNET3_State *s, uint32_t h, uint32_t l)
+{
+    s->conf.macaddr.a[0] = _GET_BYTE(l,  0);
+    s->conf.macaddr.a[1] = _GET_BYTE(l,  1);
+    s->conf.macaddr.a[2] = _GET_BYTE(l,  2);
+    s->conf.macaddr.a[3] = _GET_BYTE(l,  3);
+    s->conf.macaddr.a[4] = _GET_BYTE(h, 0);
+    s->conf.macaddr.a[5] = _GET_BYTE(h, 1);
+
+    DCFPRINTF("Variable MAC: " MAC_FMT, MAC_ARG(s->conf.macaddr.a));
+
+    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
+}
+
+static uint64_t vmxnet3_get_mac_low(MACAddr *addr)
+{
+    return _MAKE_BYTE(0, addr->a[0]) |
+           _MAKE_BYTE(1, addr->a[1]) |
+           _MAKE_BYTE(2, addr->a[2]) |
+           _MAKE_BYTE(3, addr->a[3]);
+}
+
+static uint64_t vmxnet3_get_mac_high(MACAddr *addr)
+{
+    return _MAKE_BYTE(0, addr->a[4]) |
+           _MAKE_BYTE(1, addr->a[5]);
+}
+
+static void
+vmxnet3_inc_tx_consumption_counter(VMXNET3_State *s, int qidx)
+{
+    vmxnet3_ring_inc(&s->txq_descr[qidx].tx_ring);
+}
+
+static inline void
+vmxnet3_inc_rx_consumption_counter(VMXNET3_State *s, int qidx, int ridx)
+{
+    vmxnet3_ring_inc(&s->rxq_descr[qidx].rx_ring[ridx]);
+}
+
+static inline void
+vmxnet3_inc_tx_completion_counter(VMXNET3_State *s, int qidx)
+{
+    vmxnet3_ring_inc(&s->txq_descr[qidx].comp_ring);
+}
+
+static void
+vmxnet3_inc_rx_completion_counter(VMXNET3_State *s, int qidx)
+{
+    vmxnet3_ring_inc(&s->rxq_descr[qidx].comp_ring);
+}
+
+static void
+vmxnet3_dec_rx_completion_counter(VMXNET3_State *s, int qidx)
+{
+    vmxnet3_ring_dec(&s->rxq_descr[qidx].comp_ring);
+}
+
+static inline void vmxnet3_flush_shmem_changes(void)
+{
+    /* Flush shared memory changes                  */
+    /* Needed before transferring comntrol to guest */
+    smp_wmb();
+}
+
+static void vmxnet3_complete_packet(VMXNET3_State *s, int qidx, uint32 tx_ridx)
+{
+    struct Vmxnet3_TxCompDesc txcq_descr;
+
+    vmxnet3_ring_dump(DRIPRINTF, "TXC", qidx, &s->txq_descr[qidx].comp_ring);
+
+    txcq_descr.txdIdx = tx_ridx;
+    txcq_descr.gen = vmxnet3_ring_curr_gen(&s->txq_descr[qidx].comp_ring);
+
+    vmxnet3_ring_write_curr_cell(&s->txq_descr[qidx].comp_ring, &txcq_descr);
+    vmxnet3_inc_tx_completion_counter(s, qidx);
+
+    vmxnet3_flush_shmem_changes();
+    vmxnet3_trigger_interrupt(s, s->txq_descr[qidx].intr_idx);
+}
+
+static bool
+vmxnet3_setup_tx_offloads(Vmxnet3_TxPkt *pkt)
+{
+    Vmxnet3_TxPktMdata *mdata = vmxnet3_txpkt_get_mdata(pkt);
+    struct virtio_net_hdr *vhdr = vmxnet3_txpkt_get_vhdr(pkt);
+    bool res = true;
+
+    vhdr->hdr_len = mdata->hdr_length;
+
+    switch (mdata->offload_mode) {
+    case VMXNET3_OM_NONE:
+        vhdr->flags = 0;
+        vhdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
+        vhdr->gso_size = 0;
+        break;
+
+    case VMXNET3_OM_CSUM: {
+            DPKPRINTF("L4 CSO requested data_offset: %d, csoff: %d",
+                      mdata->hdr_length, mdata->cso_or_gso_size);
+            vhdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
+            vhdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
+            vhdr->gso_size = 0;
+            vhdr->csum_start = mdata->hdr_length;
+            vhdr->csum_offset = mdata->cso_or_gso_size - mdata->hdr_length;
+        }
+        break;
+
+    case VMXNET3_OM_TSO: {
+            uint8_t  *l2hdr = vmxnet3_txpkt_get_l2hdr(pkt);
+            size_t    l2hdr_len = vmxnet3_txpkt_get_l2hdr_len(pkt);
+            uint8_t  *l3hdr = vmxnet3_txpkt_get_l3hdr(pkt);
+            size_t    l3hdr_len = vmxnet3_txpkt_get_l3hdr_len(pkt);
+            uint16_t  l3_proto = eth_get_l3_proto(l2hdr, l2hdr_len);
+            size_t    payload_len = vmxnet3_txpkt_get_payload_len(pkt);
+
+            vhdr->gso_type = eth_get_gso_type(l3_proto, l3hdr);
+            vhdr->gso_size = mdata->cso_or_gso_size;
+            res = eth_setup_tx_offloads(l3hdr, l3hdr_len, l2hdr_len,
+                                        payload_len, vhdr,
+                                        vmxnet3_txpkt_get_more_frags(pkt),
+                                        vmxnet3_txpkt_get_frag_off(pkt));
+            DPKPRINTF("GSO offload type %d requested.", vhdr->gso_type);
+        }
+        break;
+
+    default:
+        assert(false);
+    }
+
+    return res;
+}
+
+static size_t
+vmxnet3_txpkt_adopt_headers(Vmxnet3_TxPkt *pkt,
+                            size_t data_len,
+                            target_phys_addr_t data_pa,
+                            bool needs_tso)
+{
+    /* Copy L2 header */
+    uint8_t *l2hdr = vmxnet3_txpkt_get_l2hdr(pkt);
+    uint8_t *l3hdr = vmxnet3_txpkt_get_l3hdr(pkt);
+    size_t l2hdr_len = 0;
+    size_t l3hdr_len = 0;
+
+    assert(data_len >= ETH_MAX_L2_HDR_LEN);
+    cpu_physical_memory_read(data_pa, l2hdr, ETH_MAX_L2_HDR_LEN);
+    l2hdr_len = eth_get_l2_hdr_length(l2hdr);
+    vmxnet3_txpkt_set_l2hdr_len(pkt, l2hdr_len);
+
+    /* If packet requires offload - copy L3 header */
+    if (needs_tso) {
+        switch (eth_get_l3_proto(l2hdr, l2hdr_len)) {
+            case ETH_P_IP: {
+                target_phys_addr_t ip_opt_pa;
+                struct ip_header *iphdr = (struct ip_header *) l3hdr;
+                assert(data_len >= l2hdr_len + sizeof(struct ip_header));
+                cpu_physical_memory_read(data_pa + l2hdr_len,
+                                         l3hdr, sizeof(struct ip_header));
+                l3hdr_len = IP_HDR_GET_LEN(l3hdr);
+                ip_opt_pa = data_pa + l2hdr_len + sizeof(struct ip_header);
+                cpu_physical_memory_read(ip_opt_pa,
+                                         l3hdr + sizeof(struct ip_header),
+                                         l3hdr_len - sizeof(struct ip_header));
+                pkt->max_payload_len =
+                    IP_FRAG_ALIGN_SIZE(VMXNET3_MAX_IP_PLOAD_LEN);
+                pkt->fragmentation.orig_more_frags =
+                    FLAG_IS_SET(be16_to_cpu(iphdr->ip_off), IP_MF);
+            }
+            break;
+
+            case ETH_P_IPV6: {
+                target_phys_addr_t l3hdr_pa = data_pa + l2hdr_len;
+                l3hdr_len = sizeof(struct ip6_header);
+                assert(data_len >= l2hdr_len + l3hdr_len);
+                cpu_physical_memory_read(l3hdr_pa, l3hdr, l3hdr_len);
+                pkt->max_payload_len = 0;
+            }
+            break;
+
+            default: {
+                l3hdr_len = 0;
+                pkt->max_payload_len = 0;
+            }
+            break;
+        }
+    }
+
+    vmxnet3_txpkt_set_l3hdr_len(pkt, l3hdr_len);
+
+    /* Return amount of data adopted */
+    return l2hdr_len + l3hdr_len;
+}
+
+static void
+vmxnet3_tx_retrieve_metadata(Vmxnet3_TxPkt *pkt,
+                             const struct Vmxnet3_TxDesc *txd)
+{
+    struct eth_header *ehdr =
+        (struct eth_header *) vmxnet3_txpkt_get_l2hdr(pkt);
+
+    Vmxnet3_TxPktMdata *mdata = vmxnet3_txpkt_get_mdata(pkt);
+    mdata->offload_mode = txd->om;
+    mdata->cso_or_gso_size = txd->msscof;
+    mdata->hdr_length = txd->hlen;
+    mdata->packet_type = get_eth_packet_type(ehdr);
+
+    if (txd->ti) {
+        eth_setup_vlan_headers(ehdr, txd->tci);
+    }
+}
+
+static size_t
+vmxnet3_txpkt_adopt_data_fragment(Vmxnet3_TxPkt *pkt,
+                                  target_phys_addr_t data_pa,
+                                  size_t data_len,
+                                  uint32_t fragment_num)
+{
+    struct iovec *v = vmxnet3_txpkt_get_payload_frag(pkt, fragment_num);
+    size_t bytes_to_adopt = data_len;
+
+    if ((0 != pkt->max_payload_len) &&
+       (pkt->payload_len + data_len > pkt->max_payload_len)) {
+        bytes_to_adopt = pkt->max_payload_len - pkt->payload_len;
+    }
+
+    v->iov_base = (void *) (uint64_t) data_pa;
+    v->iov_len = bytes_to_adopt;
+    pkt->payload_len += bytes_to_adopt;
+    return bytes_to_adopt;
+}
+
+typedef enum {
+    VMXNET3_SUCCEEDED = 0xBEEFBEEF,
+    VMXNET3_OUT_OF_BUF,
+    VMXNET3_PKT_ERROR
+} Vmxnet3_PktStatus;
+
+static void
+vmxnet3_on_tx_done_update_stats(VMXNET3_State *s,
+                                Vmxnet3_TxPkt *pkt,
+                                int qidx,
+                                Vmxnet3_PktStatus status)
+{
+    Vmxnet3_TxPktMdata *mdata = vmxnet3_txpkt_get_mdata(&s->curr_txpkt);
+    size_t tot_len = vmxnet3_txpkt_get_total_len(pkt);
+    struct UPT1_TxStats *stats = &s->txq_descr[qidx].txq_stats;
+
+    switch (status) {
+    case VMXNET3_SUCCEEDED: {
+        switch (mdata->packet_type) {
+        case VMXNET3_PKT_BCAST:
+            stats->bcastPktsTxOK++;
+            stats->bcastBytesTxOK += tot_len;
+            break;
+        case VMXNET3_PKT_MCAST:
+            stats->mcastPktsTxOK++;
+            stats->mcastBytesTxOK += tot_len;
+            break;
+        case VMXNET3_PKT_UCAST:
+            stats->ucastPktsTxOK++;
+            stats->ucastBytesTxOK += tot_len;
+            break;
+        default:
+            assert(false);
+        }
+
+        if (VMXNET3_OM_TSO == mdata->offload_mode) {
+            /* According to VMWARE headers this statistic is a number   */
+            /* of packets after segmentation but since we don't have    */
+            /* this information in QEMU model, the best we can do is to */
+            /* provide number of non-segmented packets                  */
+            stats->TSOPktsTxOK++;
+            stats->TSOBytesTxOK += tot_len;
+        }
+    }
+    break;
+
+    case VMXNET3_PKT_ERROR: {
+        stats->pktsTxDiscard++;
+    }
+    break;
+
+    case VMXNET3_OUT_OF_BUF: {
+        stats->pktsTxError++;
+    }
+    break;
+
+    default:
+        assert(false);
+    }
+}
+
+static void
+vmxnet3_on_rx_done_update_stats(VMXNET3_State *s,
+                                Vmxnet3_RxPkt *pkt,
+                                int qidx,
+                                Vmxnet3_PktStatus status)
+{
+    Vmxnet3_RxPktMdata *mdata = vmxnet3_rxpkt_get_mdata(pkt);
+    struct UPT1_RxStats *stats = &s->rxq_descr[qidx].rxq_stats;
+
+    switch (status) {
+    case VMXNET3_OUT_OF_BUF:
+        stats->pktsRxOutOfBuf++;
+        break;
+
+    case VMXNET3_PKT_ERROR:
+        stats->pktsRxError++;
+        break;
+
+    case VMXNET3_SUCCEEDED:
+        switch (mdata->packet_type) {
+        case VMXNET3_PKT_BCAST:
+            stats->bcastPktsRxOK++;
+            stats->bcastBytesRxOK += mdata->tot_len;
+            break;
+        case VMXNET3_PKT_MCAST:
+            stats->mcastPktsRxOK++;
+            stats->mcastBytesRxOK += mdata->tot_len;
+            break;
+        case VMXNET3_PKT_UCAST:
+            stats->ucastPktsRxOK++;
+            stats->ucastBytesRxOK += mdata->tot_len;
+            break;
+        default:
+            assert(false);
+        }
+
+        if (mdata->tot_len > s->mtu) {
+            stats->LROPktsRxOK++;
+            stats->LROBytesRxOK += mdata->tot_len;
+        }
+        break;
+
+    default:
+        assert(false);
+    }
+}
+
+static inline bool
+vmxnet3_pop_next_tx_descr(VMXNET3_State *s,
+                          int qidx,
+                          struct Vmxnet3_TxDesc *txd,
+                          uint32_t *descr_idx)
+{
+    Vmxnet3_Ring *ring = &s->txq_descr[qidx].tx_ring;
+
+    vmxnet3_ring_read_curr_cell(ring, txd);
+    if (txd->gen == vmxnet3_ring_curr_gen(ring)) {
+        vmxnet3_ring_dump(DRIPRINTF, "TX", qidx, ring);
+        *descr_idx = vmxnet3_ring_curr_cell_idx(ring);
+        vmxnet3_inc_tx_consumption_counter(s, qidx);
+        return true;
+    }
+
+    return false;
+}
+
+static bool
+vmxnet3_send_packet(VMXNET3_State *s, Vmxnet3_TxPkt *pkt, uint32_t qidx)
+{
+    uint32_t mapped_fragments;
+    void *mapped = vmxnet3_txpkt_map(&s->curr_txpkt, &mapped_fragments, false);
+    if (NULL != mapped) {
+        bool res;
+        if (vmxnet3_setup_tx_offloads(pkt)) {
+            vmxnet3_dump_virt_hdr(vmxnet3_txpkt_get_vhdr(pkt));
+            vmxnet3_txpkt_dump(pkt);
+            qemu_sendv_packet(&s->nic->nc, mapped, mapped_fragments);
+            vmxnet3_on_tx_done_update_stats(s, pkt, qidx, VMXNET3_SUCCEEDED);
+            res = true;
+        } else {
+            vmxnet3_on_tx_done_update_stats(s, pkt, qidx, VMXNET3_PKT_ERROR);
+            res = false;
+        }
+        vmxnet3_txpkt_unmap(pkt, false);
+        return res;
+    } else {
+        vmxnet3_on_tx_done_update_stats(s, &s->curr_txpkt,
+                                        qidx, VMXNET3_OUT_OF_BUF);
+        return false;
+    }
+}
+
+static void vmxnet3_process_tx_queue(VMXNET3_State *s, int qidx)
+{
+    struct Vmxnet3_TxDesc txd;
+    uint32_t txd_idx;
+    uint32_t data_len;
+    target_phys_addr_t data_pa;
+    size_t bytes_adopted;
+
+    for (;;) {
+        if (!vmxnet3_pop_next_tx_descr(s, qidx, &txd, &txd_idx)) {
+            break;
+        }
+
+        vmxnet3_dump_tx_descr(&txd);
+
+        if (!s->curr_txpkt_skip) {
+            data_len = (txd.len > 0) ? txd.len : VMXNET3_MAX_TX_BUF_SIZE;
+            data_pa = le64_to_cpu(txd.addr);
+
+            if (!s->curr_txpkt_header_processed) {
+                bool needs_tso = (VMXNET3_OM_TSO == txd.om);
+                bytes_adopted = vmxnet3_txpkt_adopt_headers(&s->curr_txpkt,
+                                                            data_len,
+                                                            data_pa,
+                                                            needs_tso);
+                vmxnet3_tx_retrieve_metadata(&s->curr_txpkt, &txd);
+                data_pa += bytes_adopted;
+                data_len -= bytes_adopted;
+                s->curr_txpkt_header_processed = true;
+            }
+
+            do {
+                if (0 != data_len) {
+                    int frag_num = s->curr_txpkt_pl_frags++;
+                    bytes_adopted =
+                        vmxnet3_txpkt_adopt_data_fragment(&s->curr_txpkt,
+                                                          data_pa,
+                                                          data_len,
+                                                          frag_num);
+                    data_pa += bytes_adopted;
+                    data_len -= bytes_adopted;
+                }
+
+                if ((0 != data_len) || txd.eop) {
+                    size_t frag_off;
+
+                    vmxnet3_txpkt_set_num_pl_frags(&s->curr_txpkt,
+                                                   s->curr_txpkt_pl_frags);
+
+                    vmxnet3_txpkt_set_more_frags(&s->curr_txpkt,
+                                                 (0 != data_len));
+
+                    s->curr_txpkt_skip =
+                        !vmxnet3_send_packet(s, &s->curr_txpkt, qidx);
+
+                    frag_off = vmxnet3_txpkt_get_payload_len(&s->curr_txpkt) /
+                               IP_FRAG_UNIT_SIZE;
+
+                    vmxnet3_txpkt_advance_frag_off(&s->curr_txpkt, frag_off);
+
+                    vmxnet3_txpkt_reset_payload(&s->curr_txpkt);
+                    s->curr_txpkt_pl_frags = 0;
+                }
+            } while (0 != data_len);
+        }
+
+        if (txd.eop) {
+            vmxnet3_complete_packet(s, qidx, txd_idx);
+            vmxnet3_txpkt_reset(&s->curr_txpkt);
+            s->curr_txpkt_skip = false;
+            s->curr_txpkt_header_processed = false;
+        }
+    }
+}
+
+static inline void
+vmxnet3_read_next_rx_descr(VMXNET3_State *s, int qidx, int ridx,
+                           struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)
+{
+    Vmxnet3_Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];
+    *didx = vmxnet3_ring_curr_cell_idx(ring);
+    vmxnet3_ring_read_curr_cell(ring, dbuf);
+}
+
+static inline uint8_t
+vmxnet3_get_rx_ring_gen(VMXNET3_State *s, int qidx, int ridx)
+{
+    return s->rxq_descr[qidx].rx_ring[ridx].gen;
+}
+
+static inline target_phys_addr_t
+vmxnet3_pop_rxc_descr(VMXNET3_State *s, int qidx, uint32_t *descr_gen)
+{
+    uint8_t ring_gen;
+    struct Vmxnet3_RxCompDesc rxcd;
+
+    target_phys_addr_t daddr =
+        vmxnet3_ring_curr_cell_pa(&s->rxq_descr[qidx].comp_ring);
+
+    cpu_physical_memory_read(daddr, &rxcd, sizeof(struct Vmxnet3_RxCompDesc));
+    ring_gen = vmxnet3_ring_curr_gen(&s->rxq_descr[qidx].comp_ring);
+
+    if (rxcd.gen != ring_gen) {
+        *descr_gen = ring_gen;
+        vmxnet3_inc_rx_completion_counter(s, qidx);
+        return daddr;
+    }
+
+    return 0;
+}
+
+static inline void
+vmxnet3_revert_rxc_descr(VMXNET3_State *s, int qidx)
+{
+    vmxnet3_dec_rx_completion_counter(s, qidx);
+}
+
+#define RXQ_IDX      (0)
+#define RX_HEAD_BODY_RING (0)
+#define RX_BODY_ONLY_RING (1)
+
+static bool
+vmxnet3_get_next_head_rx_descr(VMXNET3_State *s,
+                               struct Vmxnet3_RxDesc *descr_buf,
+                               uint32_t *descr_idx,
+                               uint32_t *ridx)
+{
+    for (;;) {
+        uint32_t ring_gen;
+        vmxnet3_read_next_rx_descr(s, RXQ_IDX, RX_HEAD_BODY_RING,
+                                   descr_buf, descr_idx);
+
+        /* If no more free descriptors - return */
+        ring_gen = vmxnet3_get_rx_ring_gen(s, RXQ_IDX, RX_HEAD_BODY_RING);
+        if (descr_buf->gen != ring_gen) {
+            return false;
+        }
+
+        /* Mark current descriptor as used/skipped */
+        vmxnet3_inc_rx_consumption_counter(s, RXQ_IDX, RX_HEAD_BODY_RING);
+
+        /* If this is what we are looking for - return */
+        if (VMXNET3_RXD_BTYPE_HEAD == descr_buf->btype) {
+            *ridx = RX_HEAD_BODY_RING;
+            return true;
+        }
+    }
+}
+
+static bool
+vmxnet3_get_next_body_rx_descr(VMXNET3_State *s,
+                               struct Vmxnet3_RxDesc *dbuf,
+                               uint32_t *didx,
+                               uint32_t *ridx)
+{
+    vmxnet3_read_next_rx_descr(s, RXQ_IDX, RX_HEAD_BODY_RING, dbuf, didx);
+
+    /* Try to find corresponding descriptor in head/body ring */
+    if ((dbuf->gen == vmxnet3_get_rx_ring_gen(s, RXQ_IDX, RX_HEAD_BODY_RING)) &&
+         (VMXNET3_RXD_BTYPE_BODY == dbuf->btype)) {
+        vmxnet3_inc_rx_consumption_counter(s, RXQ_IDX, RX_HEAD_BODY_RING);
+        *ridx = RX_HEAD_BODY_RING;
+        return true;
+    }
+
+    /* If there is no free descriptors on head/body ring or next free */
+    /* descriptor is a head descriptor switch to body only ring       */
+    vmxnet3_read_next_rx_descr(s, RXQ_IDX, RX_BODY_ONLY_RING, dbuf, didx);
+
+    /* If no more free descriptors - return */
+    if (dbuf->gen == vmxnet3_get_rx_ring_gen(s, RXQ_IDX, RX_BODY_ONLY_RING)) {
+        assert(VMXNET3_RXD_BTYPE_BODY == dbuf->btype);
+        *ridx = RX_BODY_ONLY_RING;
+        vmxnet3_inc_rx_consumption_counter(s, RXQ_IDX, RX_BODY_ONLY_RING);
+        return true;
+    }
+
+    return false;
+}
+
+static inline bool
+vmxnet3_get_next_rx_descr(VMXNET3_State *s, bool is_head,
+                          struct Vmxnet3_RxDesc *descr_buf,
+                          uint32_t *descr_idx,
+                          uint32_t *ridx)
+{
+    if (is_head || !s->rx_packets_compound) {
+        return vmxnet3_get_next_head_rx_descr(s, descr_buf, descr_idx, ridx);
+    } else {
+        return vmxnet3_get_next_body_rx_descr(s, descr_buf, descr_idx, ridx);
+    }
+}
+
+static void
+vmxnet3_rx_put_metadata_to_descr(Vmxnet3_RxPkt *pkt,
+                                 struct Vmxnet3_RxCompDesc *rxcd)
+{
+    int csum_correct, is_gso;
+    bool isip4, isip6, istcp, isudp;
+    uint8_t headers[ETH_MAX_L2_HDR_LEN + ETH_MAX_L3_HDR_LEN];
+    Vmxnet3_RxPktMdata *mdata = vmxnet3_rxpkt_get_mdata(pkt);
+    struct virtio_net_hdr *vhdr;
+    uint8_t offload_type;
+
+    if (mdata->vlan_stripped) {
+        rxcd->ts = 1;
+        rxcd->tci = mdata->vlan_tag;
+    }
+
+    if (!mdata->vhdr_valid) {
+        goto nocsum;
+    }
+
+    vhdr = vmxnet3_rxpkt_get_vhdr(pkt);
+    /* Checksum is valid when lower level tell so or when lower level      */
+    /* requires checksum offload telling that packet produced/bridged      */
+    /* locally and did travel over network after last checksum calculation */
+    /* or production                                                       */
+    csum_correct = FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_DATA_VALID) ||
+                   FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM);
+
+    offload_type = vhdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN;
+    is_gso = (offload_type != VIRTIO_NET_HDR_GSO_NONE) ? 1 : 0;
+
+    if (!csum_correct && !is_gso) {
+        goto nocsum;
+    }
+
+    /* Make linear copy of L2-L3 headers and parse it */
+    iov_to_buf(vmxnet3_rxpkt_get_frag(pkt, 0),
+               vmxnet3_rxpkt_get_num_frags(pkt),
+               headers, 0, MIN(sizeof(headers), mdata->tot_len));
+
+    eth_get_protocols(headers, MIN(sizeof(headers), mdata->tot_len),
+                      &isip4, &isip6, &isudp, &istcp);
+    if ((!istcp && !isudp) || (!isip4 && !isip6)) {
+        goto nocsum;
+    }
+
+    rxcd->cnc = 0;
+    rxcd->v4 = isip4 ? 1 : 0;
+    rxcd->v6 = isip6 ? 1 : 0;
+    rxcd->tcp = istcp ? 1 : 0;
+    rxcd->udp = isudp ? 1 : 0;
+    rxcd->fcs = rxcd->tuc = rxcd->ipc = 1;
+    return;
+
+nocsum:
+    rxcd->cnc = 1;
+    return;
+}
+
+static void
+vmxnet3_physical_memory_writev(const struct iovec *iov,
+                               size_t start_iov_off,
+                               target_phys_addr_t target_addr,
+                               size_t bytes_to_copy)
+{
+    size_t curr_off = 0;
+    size_t copied = 0;
+
+    while (bytes_to_copy) {
+        if (start_iov_off < (curr_off + iov->iov_len)) {
+            size_t chunk_len =
+                MIN((curr_off + iov->iov_len) - start_iov_off, bytes_to_copy);
+
+            cpu_physical_memory_write(target_addr + copied,
+                                      iov->iov_base + start_iov_off - curr_off,
+                                      chunk_len);
+
+            copied += chunk_len;
+            start_iov_off += chunk_len;
+            curr_off = start_iov_off;
+            bytes_to_copy -= chunk_len;
+        } else {
+            curr_off += iov->iov_len;
+        }
+        iov++;
+    }
+}
+
+static bool
+vmxnet3_indicate_packet(VMXNET3_State *s, Vmxnet3_RxPkt *pkt)
+{
+    struct Vmxnet3_RxDesc rxd;
+    bool is_head = true;
+    uint32_t rxd_idx;
+    uint32_t rx_ridx;
+
+    struct Vmxnet3_RxCompDesc rxcd;
+    uint32_t new_rxcd_gen = VMXNET3_INIT_GEN;
+    target_phys_addr_t new_rxcd_pa = 0;
+    target_phys_addr_t ready_rxcd_pa = 0;
+    struct iovec *data = vmxnet3_rxpkt_get_frag(pkt, 0);
+    Vmxnet3_RxPktMdata *mdata = vmxnet3_rxpkt_get_mdata(pkt);
+    size_t bytes_copied = 0;
+    size_t bytes_left = mdata->tot_len;
+    uint16_t num_frags = 0;
+
+    vmxnet3_rxpkt_dump(pkt);
+
+    while ((num_frags < s->max_rx_frags) &&
+          (bytes_left > 0) &&
+          (new_rxcd_pa = vmxnet3_pop_rxc_descr(s, RXQ_IDX, &new_rxcd_gen)) &&
+          vmxnet3_get_next_rx_descr(s, is_head, &rxd, &rxd_idx, &rx_ridx)) {
+        size_t chunk_size = MIN(bytes_left, rxd.len);
+        vmxnet3_physical_memory_writev(data, bytes_copied,
+                                       le64_to_cpu(rxd.addr), chunk_size);
+        bytes_copied += chunk_size;
+        bytes_left -= chunk_size;
+
+        vmxnet3_dump_rx_descr(&rxd);
+
+        if (0 != ready_rxcd_pa) {
+            cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
+        }
+
+        memset(&rxcd, 0, sizeof(struct Vmxnet3_RxCompDesc));
+        rxcd.rxdIdx = rxd_idx;
+        rxcd.len = chunk_size;
+        rxcd.sop = is_head;
+        rxcd.gen = new_rxcd_gen;
+        rxcd.rqID = RXQ_IDX + rx_ridx*s->rxq_num;
+
+        if (0 == bytes_left) {
+            vmxnet3_rx_put_metadata_to_descr(pkt, &rxcd);
+        }
+
+        DRIPRINTF("RX Completion descriptor: rxRing: %lu rxIdx %lu len %lu "
+                  "sop %d csum_correct %lu",
+                  (unsigned long) rx_ridx,
+                  (unsigned long) rxcd.rxdIdx,
+                  (unsigned long) rxcd.len,
+                  (int) rxcd.sop,
+                  (unsigned long) rxcd.tuc);
+
+        is_head = false;
+        ready_rxcd_pa = new_rxcd_pa;
+        new_rxcd_pa = 0;
+    }
+
+    if (0 != ready_rxcd_pa) {
+        rxcd.eop = 1;
+        rxcd.err = (0 != bytes_left);
+        cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
+        vmxnet3_flush_shmem_changes();
+    }
+
+    if (0 != new_rxcd_pa) {
+        vmxnet3_revert_rxc_descr(s, RXQ_IDX);
+    }
+
+    vmxnet3_trigger_interrupt(s, s->rxq_descr[RXQ_IDX].intr_idx);
+
+    if (bytes_left == 0) {
+        vmxnet3_on_rx_done_update_stats(s, pkt, RXQ_IDX, VMXNET3_SUCCEEDED);
+        return true;
+    } else if (num_frags == s->max_rx_frags) {
+        vmxnet3_on_rx_done_update_stats(s, pkt, RXQ_IDX, VMXNET3_PKT_ERROR);
+        return false;
+    } else {
+        vmxnet3_on_rx_done_update_stats(s, pkt, RXQ_IDX, VMXNET3_OUT_OF_BUF);
+        return false;
+    }
+}
+
+static void
+vmxnet3_io_bar0_write(void *opaque, target_phys_addr_t addr,
+                      uint64_t val, unsigned size)
+{
+    VMXNET3_State *s = opaque;
+
+    if (IS_MULTIREG_ADDR(addr, VMXNET3_REG_TXPROD,
+                        VMXNET3_DEVICE_MAX_TX_QUEUES, VMXNET3_REG_ALIGN)) {
+        int tx_queue_idx =
+            MULTIREG_IDX_BY_ADDR(addr, VMXNET3_REG_TXPROD, VMXNET3_REG_ALIGN);
+        assert(tx_queue_idx <= s->txq_num);
+        vmxnet3_process_tx_queue(s, tx_queue_idx);
+        return;
+    }
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+    if (IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
+                        VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
+        int l = MULTIREG_IDX_BY_ADDR(addr, VMXNET3_REG_IMR, VMXNET3_REG_ALIGN);
+
+        DCBPRINTF("Interrupt mask for line %d written: 0x%" PRIx64, l, val);
+
+        vmxnet3_on_interrupt_mask_changed(s, l, val);
+        return;
+    }
+#pragma GCC diagnostic pop
+
+    if (IS_MULTIREG_ADDR(addr, VMXNET3_REG_RXPROD,
+                        VMXNET3_DEVICE_MAX_RX_QUEUES, VMXNET3_REG_ALIGN) ||
+       IS_MULTIREG_ADDR(addr, VMXNET3_REG_RXPROD2,
+                        VMXNET3_DEVICE_MAX_RX_QUEUES, VMXNET3_REG_ALIGN)) {
+        return;
+    }
+
+    DWRPRINTF("BAR0 unknown write [%" PRIx64 "] = %" PRIx64 ", size %d",
+              (uint64_t) addr, val, size);
+}
+
+static uint64_t
+vmxnet3_io_bar0_read(void *opaque, target_phys_addr_t addr, unsigned size)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+    if (IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
+                        VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
+        assert(false);
+    }
+#pragma GCC diagnostic pop
+
+    DCBPRINTF("BAR0 unknown read [%" PRIx64 "], size %d",
+              (uint64_t) addr, size);
+    return 0;
+}
+
+static void vmxnet3_reset(VMXNET3_State *s)
+{
+    DCBPRINTF("Resetting vmxnet3...");
+
+    vmxnet3_txpkt_reset(&s->curr_txpkt);
+    s->curr_txpkt_pl_frags = 0;
+    s->curr_txpkt_skip = false;
+    s->curr_txpkt_header_processed = false;
+}
+
+static void vmxnet3_deactivate_device(VMXNET3_State *s)
+{
+    DCBPRINTF("Deactivating vmxnet3...");
+    s->device_active = false;
+}
+
+static void vmxnet3_update_rx_mode(VMXNET3_State *s)
+{
+    s->rx_mode = VMXNET3_READ_DRV_SHARED32(s->drv_shmem,
+                                           devRead.rxFilterConf.rxMode);
+    DCFPRINTF("RX mode: 0x%08X", s->rx_mode);
+}
+
+static void vmxnet3_update_vlan_filters(VMXNET3_State *s)
+{
+    int i;
+
+    /* Copy configuration from shared memory */
+    VMXNET3_READ_DRV_SHARED(s->drv_shmem,
+                            devRead.rxFilterConf.vfTable,
+                            s->vlan_table,
+                            sizeof(s->vlan_table));
+
+    /* Invert byte order when needed */
+    for (i = 0; i < ARRAY_SIZE(s->vlan_table); i++) {
+        s->vlan_table[i] = le32_to_cpu(s->vlan_table[i]);
+    }
+
+    /* Dump configuration for debugging purposes */
+    DCFPRINTF("Configured VLANs:");
+    for (i = 0; i < sizeof(s->vlan_table) * 8; i++) {
+        if (VMXNET3_VFTABLE_ENTRY_IS_SET(s->vlan_table, i)) {
+            DCFPRINTF("\tVLAN %d is present", i);
+        }
+    }
+}
+
+static void vmxnet3_update_mcast_filters(VMXNET3_State *s)
+{
+    uint16_t list_bytes =
+        VMXNET3_READ_DRV_SHARED16(s->drv_shmem,
+                                  devRead.rxFilterConf.mfTableLen);
+
+    s->mcast_list_len = list_bytes / sizeof(s->mcast_list[0]);
+
+    s->mcast_list = g_realloc(s->mcast_list, list_bytes);
+    if (NULL == s->mcast_list) {
+        if (0 == s->mcast_list_len) {
+            DCFPRINTF("Current multicast list is empty");
+        } else {
+            DERPRINTF("Failed to allocate multicast list of %d elements",
+                      s->mcast_list_len);
+        }
+        s->mcast_list_len = 0;
+    } else {
+        int i;
+        target_phys_addr_t mcast_list_pa =
+            VMXNET3_READ_DRV_SHARED64(s->drv_shmem,
+                                      devRead.rxFilterConf.mfTablePA);
+
+        cpu_physical_memory_read(mcast_list_pa, s->mcast_list, list_bytes);
+        DCFPRINTF("Current multicast list len is %d:", s->mcast_list_len);
+        for (i = 0; i < s->mcast_list_len; i++) {
+            DCFPRINTF("\t" MAC_FMT, MAC_ARG(s->mcast_list[i].a));
+        }
+    }
+}
+
+static void vmxnet3_setup_rx_filtering(VMXNET3_State *s)
+{
+    vmxnet3_update_rx_mode(s);
+    vmxnet3_update_vlan_filters(s);
+    vmxnet3_update_mcast_filters(s);
+}
+
+static uint32_t vmxnet3_get_interrupt_config(VMXNET3_State *s)
+{
+    uint32_t interrupt_mode = VMXNET3_IT_AUTO | (VMXNET3_IMM_AUTO << 2);
+    DCFPRINTF("Interrupt config is 0x%X", interrupt_mode);
+    return interrupt_mode;
+}
+
+static void vmxnet3_fill_stats(VMXNET3_State *s)
+{
+    int i;
+    for (i = 0; i < s->txq_num; i++) {
+        cpu_physical_memory_write(s->txq_descr[i].tx_stats_pa,
+                                  &s->txq_descr[i].txq_stats,
+                                  sizeof(s->txq_descr[i].txq_stats));
+    }
+
+    for (i = 0; i < s->rxq_num; i++) {
+        cpu_physical_memory_write(s->rxq_descr[i].rx_stats_pa,
+                                  &s->rxq_descr[i].rxq_stats,
+                                  sizeof(s->rxq_descr[i].rxq_stats));
+    }
+}
+
+static void vmxnet3_adjust_by_guest_type(VMXNET3_State *s)
+{
+    struct Vmxnet3_GOSInfo gos;
+
+    VMXNET3_READ_DRV_SHARED(s->drv_shmem, devRead.misc.driverInfo.gos,
+                            &gos, sizeof(gos));
+    s->rx_packets_compound =
+        (VMXNET3_GOS_TYPE_WIN == gos.gosType) ? false : true;
+
+    DCFPRINTF("Guest type specifics: RXCOMPOUND: %d", s->rx_packets_compound);
+}
+
+static void
+vmxnet3_dump_conf_descr(const char *name,
+                        struct Vmxnet3_VariableLenConfDesc *pm_descr)
+{
+    DCFPRINTF("%s descriptor dump: Version %u, Length %u",
+              name, pm_descr->confVer, pm_descr->confLen);
+
+};
+
+static void vmxnet3_update_pm_state(VMXNET3_State *s)
+{
+    struct Vmxnet3_VariableLenConfDesc pm_descr;
+
+    pm_descr.confLen =
+        VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.pmConfDesc.confLen);
+    pm_descr.confVer =
+        VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.pmConfDesc.confVer);
+    pm_descr.confPA =
+        VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.pmConfDesc.confPA);
+
+    vmxnet3_dump_conf_descr("PM State", &pm_descr);
+}
+
+static void vmxnet3_update_features(VMXNET3_State *s)
+{
+    uint32_t guest_features;
+    int rxcsum_offload_supported;
+
+    guest_features = VMXNET3_READ_DRV_SHARED32(s->drv_shmem,
+                                               devRead.misc.uptFeatures);
+
+    rxcsum_offload_supported = FLAG_IS_SET(guest_features, UPT1_F_RXCSUM);
+    s->rx_vlan_stripping = FLAG_IS_SET(guest_features, UPT1_F_RXVLAN);
+    s->lro_supported = FLAG_IS_SET(guest_features, UPT1_F_LRO);
+
+    DCFPRINTF("Features configuration: LRO: %d, RXCSUM: %d, VLANSTRIP: %d",
+              s->lro_supported, rxcsum_offload_supported,
+              s->rx_vlan_stripping);
+
+    tap_set_offload(s->nic->nc.peer,
+                    rxcsum_offload_supported,
+                    s->lro_supported,
+                    s->lro_supported,
+                    0,
+                    0);
+}
+
+static void vmxnet3_activate_device(VMXNET3_State *s)
+{
+    int i;
+    static const uint32_t VMXNET3_DEF_TX_THRESHOLD = 1;
+    target_phys_addr_t qdescr_table_pa;
+    uint64_t pa;
+    uint32_t size;
+
+    /* Verify configuration consistency */
+    if (!vmxnet3_verify_driver_magic(s->drv_shmem)) {
+        DERPRINTF("Device configuration received from driver is invalid");
+        return;
+    }
+
+    vmxnet3_adjust_by_guest_type(s);
+    vmxnet3_update_features(s);
+    vmxnet3_update_pm_state(s);
+    vmxnet3_setup_rx_filtering(s);
+    /* Cache fields from shared memory */
+    s->mtu = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, devRead.misc.mtu);
+    DCFPRINTF("MTU is %u", s->mtu);
+
+    s->max_rx_frags =
+        VMXNET3_READ_DRV_SHARED16(s->drv_shmem, devRead.misc.maxNumRxSG);
+
+    DCFPRINTF("Max RX fragments is %u", s->max_rx_frags);
+
+    s->event_int_idx =
+        VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx);
+    DCFPRINTF("Events interrupt line is %u", s->event_int_idx);
+
+    s->auto_int_masking =
+        VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.autoMask);
+    DCFPRINTF("Automatic interrupt masking is %d", (int)s->auto_int_masking);
+
+    s->txq_num =
+        VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numTxQueues);
+    s->rxq_num =
+        VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.misc.numRxQueues);
+
+    DCFPRINTF("Number of TX/RX queues %u/%u", s->txq_num, s->rxq_num);
+    assert(s->txq_num <= VMXNET3_DEVICE_MAX_TX_QUEUES);
+
+    qdescr_table_pa =
+        VMXNET3_READ_DRV_SHARED64(s->drv_shmem, devRead.misc.queueDescPA);
+    DCFPRINTF("TX queues descriptors table is at 0x%" PRIx64,
+              (uint64_t) qdescr_table_pa);
+
+    /* Worst-case scenario is a packet that holds all TX rings space so    */
+    /* we calculate total size of all TX rings for max TX fragments number */
+    s->max_tx_frags = 0;
+
+    /* TX queues */
+    for (i = 0; i < s->txq_num; i++) {
+        target_phys_addr_t qdescr_pa =
+            qdescr_table_pa + i*sizeof(struct Vmxnet3_TxQueueDesc);
+
+        /* Read interrupt number for this TX queue */
+        s->txq_descr[i].intr_idx =
+            VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx);
+
+        DCFPRINTF("TX Queue %d interrupt: %d", i, s->txq_descr[i].intr_idx);
+
+        /* Read rings memory locations for TX queues */
+        pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.txRingBasePA);
+        size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.txRingSize);
+
+        vmxnet3_ring_init(&s->txq_descr[i].tx_ring, pa, size,
+                          sizeof(struct Vmxnet3_TxDesc), false);
+        vmxnet3_ring_dump(DCFPRINTF, "TX", i, &s->txq_descr[i].tx_ring);
+
+        s->max_tx_frags += size;
+
+        /* TXC ring */
+        pa = VMXNET3_READ_TX_QUEUE_DESCR64(qdescr_pa, conf.compRingBasePA);
+        size = VMXNET3_READ_TX_QUEUE_DESCR32(qdescr_pa, conf.compRingSize);
+        vmxnet3_ring_init(&s->txq_descr[i].comp_ring, pa, size,
+                          sizeof(struct Vmxnet3_TxCompDesc), true);
+        vmxnet3_ring_dump(DCFPRINTF, "TXC", i, &s->txq_descr[i].comp_ring);
+
+        s->txq_descr[i].tx_stats_pa =
+            qdescr_pa + offsetof(struct Vmxnet3_TxQueueDesc, stats);
+
+        memset(&s->txq_descr[i].txq_stats, 0,
+               sizeof(s->txq_descr[i].txq_stats));
+
+        /* Fill device-managed parameters for queues */
+        VMXNET3_WRITE_TX_QUEUE_DESCR32(qdescr_pa,
+                                       ctrl.txThreshold,
+                                       VMXNET3_DEF_TX_THRESHOLD);
+    }
+
+    /* Preallocate TX packet wrapper */
+    DCFPRINTF("Max TX fragments is %u", s->max_tx_frags);
+    if (!vmxnet3_txpkt_prealloc(&s->curr_txpkt, s->max_tx_frags,
+                               s->peer_has_vhdr)) {
+        hw_error("TX rings configuration problem");
+    }
+
+    /* Read rings memory locations for RX queues */
+    for (i = 0; i < s->rxq_num; i++) {
+        int j;
+        target_phys_addr_t qd_pa =
+            qdescr_table_pa + s->txq_num*sizeof(struct Vmxnet3_TxQueueDesc) +
+            i*sizeof(struct Vmxnet3_RxQueueDesc);
+
+        /* Read interrupt number for this RX queue */
+        s->rxq_descr[i].intr_idx =
+            VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx);
+
+        DCFPRINTF("RX Queue %d interrupt: %d", i, s->rxq_descr[i].intr_idx);
+
+        /* Read rings memory locations */
+        for (j = 0; j < VMXNET3_RX_RINGS_PER_QUEUE; j++) {
+            /* RX rings */
+            pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.rxRingBasePA[j]);
+            size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.rxRingSize[j]);
+            vmxnet3_ring_init(&s->rxq_descr[i].rx_ring[j], pa, size,
+                              sizeof(struct Vmxnet3_RxDesc), false);
+            DCFPRINTF("RX queue %d:%d: Base: %" PRIx64 ", Size: %d",
+                      i, j, pa, size);
+        }
+
+        /* RXC ring */
+        pa = VMXNET3_READ_RX_QUEUE_DESCR64(qd_pa, conf.compRingBasePA);
+        size = VMXNET3_READ_RX_QUEUE_DESCR32(qd_pa, conf.compRingSize);
+        vmxnet3_ring_init(&s->rxq_descr[i].comp_ring, pa, size,
+                          sizeof(struct Vmxnet3_RxCompDesc), true);
+        DCFPRINTF("RXC queue %d: Base: %" PRIx64 ", Size: %d", i, pa, size);
+
+        s->rxq_descr[i].rx_stats_pa =
+            qd_pa + offsetof(struct Vmxnet3_RxQueueDesc, stats);
+        memset(&s->rxq_descr[i].rxq_stats, 0,
+               sizeof(s->rxq_descr[i].rxq_stats));
+    }
+
+    vmxnet3_flush_shmem_changes();
+    s->device_active = true;
+}
+
+static void vmxnet3_handle_command(VMXNET3_State *s, uint64_t cmd)
+{
+    s->last_command = cmd;
+
+    switch (cmd) {
+    case VMXNET3_CMD_GET_PERM_MAC_HI:
+        DCBPRINTF("Set: Get upper part of permanent MAC");
+        break;
+
+    case VMXNET3_CMD_GET_PERM_MAC_LO:
+        DCBPRINTF("Set: Get lower part of permanent MAC");
+        break;
+
+    case VMXNET3_CMD_GET_STATS:
+        DCBPRINTF("Set: Get device statistics");
+        vmxnet3_fill_stats(s);
+        break;
+
+    case VMXNET3_CMD_ACTIVATE_DEV:
+        DCBPRINTF("Set: Activating vmxnet3 device");
+        vmxnet3_activate_device(s);
+        break;
+
+    case VMXNET3_CMD_UPDATE_RX_MODE:
+        DCBPRINTF("Set: Update rx mode");
+        vmxnet3_update_rx_mode(s);
+        break;
+
+    case VMXNET3_CMD_UPDATE_VLAN_FILTERS:
+        DCBPRINTF("Set: Update VLAN filters");
+        vmxnet3_update_vlan_filters(s);
+        break;
+
+    case VMXNET3_CMD_UPDATE_MAC_FILTERS:
+        DCBPRINTF("Set: Update MAC filters");
+        vmxnet3_update_mcast_filters(s);
+        break;
+
+    case VMXNET3_CMD_UPDATE_FEATURE:
+        DCBPRINTF("Set: Update features");
+        vmxnet3_update_features(s);
+        break;
+
+    case VMXNET3_CMD_UPDATE_PMCFG:
+        DCBPRINTF("Set: Update power management config");
+        vmxnet3_update_pm_state(s);
+        break;
+
+    case VMXNET3_CMD_GET_LINK:
+        DCBPRINTF("Set: Get link");
+        break;
+
+    case VMXNET3_CMD_RESET_DEV:
+        DCBPRINTF("Set: Reset device");
+        vmxnet3_reset(s);
+        break;
+
+    case VMXNET3_CMD_QUIESCE_DEV:
+        DCBPRINTF("Set: VMXNET3_CMD_QUIESCE_DEV - pause the device");
+        vmxnet3_deactivate_device(s);
+        break;
+
+    case VMXNET3_CMD_GET_CONF_INTR:
+        DCBPRINTF("Set: VMXNET3_CMD_GET_CONF_INTR - interrupt configuration");
+        break;
+
+    default:
+        DCBPRINTF("Received unknown command: %" PRIx64, cmd);
+        break;
+    }
+}
+
+static uint64_t vmxnet3_get_command_status(VMXNET3_State *s)
+{
+    uint64_t ret;
+
+    switch (s->last_command) {
+    case VMXNET3_CMD_ACTIVATE_DEV:
+        ret = (s->device_active) ? 0 : -1;
+        DCFPRINTF("Device active: %" PRIx64, ret);
+        break;
+
+    case VMXNET3_CMD_GET_LINK:
+        ret = s->link_status_and_speed;
+        DCFPRINTF("Link and speed: %" PRIx64, ret);
+        break;
+
+    case VMXNET3_CMD_GET_PERM_MAC_LO:
+        ret = vmxnet3_get_mac_low(&s->perm_mac);
+        break;
+
+    case VMXNET3_CMD_GET_PERM_MAC_HI:
+        ret = vmxnet3_get_mac_high(&s->perm_mac);
+        break;
+
+    case VMXNET3_CMD_GET_CONF_INTR:
+        ret = vmxnet3_get_interrupt_config(s);
+        break;
+
+    default:
+        DWRPRINTF("Received request for unknown command: %x", s->last_command);
+        ret = -1;
+        break;
+    }
+
+    return ret;
+}
+
+static void vmxnet3_set_events(VMXNET3_State *s, uint32_t val)
+{
+    uint32_t events;
+
+    DCBPRINTF("Setting events: 0x%x", val);
+    events = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, ecr) | val;
+    VMXNET3_WRITE_DRV_SHARED32(s->drv_shmem, ecr, events);
+}
+
+static void vmxnet3_ack_events(VMXNET3_State *s, uint32_t val)
+{
+    uint32_t events;
+
+    DCBPRINTF("Clearing events: 0x%x", val);
+    events = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, ecr) & ~val;
+    VMXNET3_WRITE_DRV_SHARED32(s->drv_shmem, ecr, events);
+}
+
+static void
+vmxnet3_io_bar1_write(void *opaque,
+                      target_phys_addr_t addr,
+                      uint64_t val,
+                      unsigned size)
+{
+    VMXNET3_State *s = opaque;
+
+    switch (addr) {
+    /* Vmxnet3 Revision Report Selection */
+    case VMXNET3_REG_VRRS:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_VRRS] = %" PRIx64 ", size %d",
+                  val, size);
+        break;
+
+    /* UPT Version Report Selection */
+    case VMXNET3_REG_UVRS:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_UVRS] = %" PRIx64 ", size %d",
+                  val, size);
+        break;
+
+    /* Driver Shared Address Low */
+    case VMXNET3_REG_DSAL:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_DSAL] = %" PRIx64 ", size %d",
+                  val, size);
+        /* Guest driver will first write the low part of the shared */
+        /* memory address. We save it to temp variable and set the  */
+        /* shared address only after we get the high part           */
+        if (0 == val) {
+            s->device_active = false;
+        }
+        s->temp_shared_guest_driver_memory = val;
+        s->drv_shmem = 0;
+        break;
+
+    /* Driver Shared Address High */
+    case VMXNET3_REG_DSAH:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_DSAH] = %" PRIx64 ", size %d",
+                  val, size);
+        /* Set the shared memory between guest driver and device. */
+        /* We already should have low address part.               */
+        s->drv_shmem = s->temp_shared_guest_driver_memory | (val << 32);
+        break;
+
+    /* Command */
+    case VMXNET3_REG_CMD:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_CMD] = %" PRIx64 ", size %d",
+                  val, size);
+        vmxnet3_handle_command(s, val);
+        break;
+
+    /* MAC Address Low */
+    case VMXNET3_REG_MACL:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_MACL] = %" PRIx64 ", size %d",
+                  val, size);
+        s->temp_mac = val;
+        break;
+
+    /* MAC Address High */
+    case VMXNET3_REG_MACH:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_MACH] = %" PRIx64 ", size %d",
+                  val, size);
+        vmxnet3_set_variable_mac(s, val, s->temp_mac);
+        break;
+
+    /* Interrupt Cause Register */
+    case VMXNET3_REG_ICR:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
+                  val, size);
+        assert(false);
+        break;
+
+    /* Event Cause Register */
+    case VMXNET3_REG_ECR:
+        DCBPRINTF("Write BAR1 [VMXNET3_REG_ECR] = %" PRIx64 ", size %d",
+                  val, size);
+        vmxnet3_ack_events(s, val);
+        break;
+
+    default:
+        DCBPRINTF("Unknown Write to BAR1 [%" PRIx64 "] = %" PRIx64 ", size %d",
+                  (uint64_t) addr, val, size);
+        break;
+    }
+}
+
+static uint64_t
+vmxnet3_io_bar1_read(void *opaque, target_phys_addr_t addr, unsigned size)
+{
+        VMXNET3_State *s = opaque;
+        uint64_t ret = 0;
+
+        switch (addr) {
+        /* Vmxnet3 Revision Report Selection */
+        case VMXNET3_REG_VRRS:
+            DCBPRINTF("Read BAR1 [VMXNET3_REG_VRRS], size %d", size);
+            ret = VMXNET3_DEVICE_REVISION;
+            break;
+
+        /* UPT Version Report Selection */
+        case VMXNET3_REG_UVRS:
+            DCBPRINTF("Read BAR1 [VMXNET3_REG_UVRS], size %d", size);
+            ret = VMXNET3_DEVICE_VERSION;
+            break;
+
+        /* Command */
+        case VMXNET3_REG_CMD:
+            DCBPRINTF("Read BAR1 [VMXNET3_REG_CMD], size %d", size);
+            ret = vmxnet3_get_command_status(s);
+            break;
+
+        /* MAC Address Low */
+        case VMXNET3_REG_MACL:
+            DCBPRINTF("Read BAR1 [VMXNET3_REG_MACL], size %d", size);
+            ret = vmxnet3_get_mac_low(&s->conf.macaddr);
+            break;
+
+        /* MAC Address High */
+        case VMXNET3_REG_MACH:
+            DCBPRINTF("Read BAR1 [VMXNET3_REG_MACH], size %d", size);
+            ret = vmxnet3_get_mac_high(&s->conf.macaddr);
+            break;
+
+        /* Interrupt Cause Register                                    */
+        /* Used for legacy interrupts only so interrupt index always 0 */
+        case VMXNET3_REG_ICR:
+            DCBPRINTF("Read BAR1 [VMXNET3_REG_ICR], size %d", size);
+            if (vmxnet3_interrupt_asserted(s, 0)) {
+                vmxnet3_clear_interrupt(s, 0);
+                ret = true;
+            } else {
+                ret = false;
+            }
+            break;
+
+        default:
+            DCBPRINTF("Unknow read BAR1[%" PRIx64 "], %d bytes",
+                      (uint64_t) addr, size);
+            break;
+        }
+
+        return ret;
+}
+
+static int
+vmxnet3_can_receive(VLANClientState *nc)
+{
+    VMXNET3_State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+    return s->device_active &&
+           FLAG_IS_SET(s->link_status_and_speed, VMXNET3_LINK_STATUS_UP);
+}
+
+static inline bool
+vmxnet3_is_registered_vlan(VMXNET3_State *s, const void *data)
+{
+    uint16_t vlan_tag = eth_get_pkt_vlan_tag(data) & VLAN_VID_MASK;
+
+    if (IS_SPECIAL_VLAN_ID(vlan_tag)) {
+        return true;
+    }
+
+    return VMXNET3_VFTABLE_ENTRY_IS_SET(s->vlan_table, vlan_tag);
+}
+
+static bool
+vmxnet3_is_allowed_mcast_group(VMXNET3_State *s, const uint8_t *group_mac)
+{
+    int i;
+    for (i = 0; i < s->mcast_list_len; i++) {
+        if (memcmp(group_mac, s->mcast_list[i].a, sizeof(s->mcast_list[i]))) {
+            return true;
+        }
+    }
+    return false;
+}
+
+static bool
+vmxnet3_rx_filter_may_indicate(VMXNET3_State *s, const void *data,
+                               size_t size, eth_pkt_types_e packet_type)
+{
+    struct eth_header *ehdr = PKT_GET_ETH_HDR(data);
+
+    if (FLAG_IS_SET(s->rx_mode, VMXNET3_RXM_PROMISC)) {
+        return true;
+    }
+
+    switch (packet_type) {
+    case VMXNET3_PKT_UCAST:
+        if (!FLAG_IS_SET(s->rx_mode, VMXNET3_RXM_UCAST)) {
+            return false;
+        }
+        if (memcmp(s->conf.macaddr.a, ehdr->h_dest, ETH_ALEN)) {
+            return false;
+        }
+        break;
+
+    case VMXNET3_PKT_BCAST:
+        if (!FLAG_IS_SET(s->rx_mode, VMXNET3_RXM_BCAST)) {
+            return false;
+        }
+        break;
+
+    case VMXNET3_PKT_MCAST:
+        if (FLAG_IS_SET(s->rx_mode, VMXNET3_RXM_ALL_MULTI)) {
+            return true;
+        }
+        if (!FLAG_IS_SET(s->rx_mode, VMXNET3_RXM_MCAST)) {
+            return false;
+        }
+        if (!vmxnet3_is_allowed_mcast_group(s, ehdr->h_dest)) {
+            return false;
+        }
+        break;
+
+    default:
+        assert(false);
+    }
+
+    return vmxnet3_is_registered_vlan(s, data);
+}
+
+static void
+vmxnet3_rxpkt_attach_data(VMXNET3_State *s, Vmxnet3_RxPkt *pkt,
+                          const void *data, size_t len)
+{
+    uint16_t vtag = 0;
+    uint16_t ploff;
+    Vmxnet3_RxPktMdata *mdata = vmxnet3_rxpkt_get_mdata(pkt);
+
+    if (s->rx_vlan_stripping) {
+        mdata->vlan_stripped =
+            eth_strip_vlan(&data, vmxnet3_rxpkt_get_ehdr(pkt), &ploff, &vtag);
+    } else {
+        mdata->vlan_stripped = false;
+    }
+
+    if (mdata->vlan_stripped) {
+        vmxnet3_rxpkt_attach_ehdr(pkt);
+        vmxnet3_rxpkt_get_frag(pkt, 1)->iov_base = (uint8_t *) data + ploff;
+        vmxnet3_rxpkt_get_frag(pkt, 1)->iov_len = len - ploff;
+        vmxnet3_rxpkt_set_num_frags(pkt, 2);
+        mdata->tot_len = len - ploff + sizeof(struct eth_header);
+    } else {
+        vmxnet3_rxpkt_get_frag(pkt, 0)->iov_base = (void *) data;
+        vmxnet3_rxpkt_get_frag(pkt, 0)->iov_len = len;
+        vmxnet3_rxpkt_set_num_frags(pkt, 1);
+        mdata->tot_len = len;
+    }
+
+    mdata->vlan_tag = vtag;
+}
+
+static ssize_t
+vmxnet3_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
+{
+    VMXNET3_State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+    Vmxnet3_RxPkt pkt;
+    size_t bytes_indicated;
+    Vmxnet3_RxPktMdata *mdata;
+
+    if (!vmxnet3_can_receive(&s->nic->nc)) {
+        DPKPRINTF("Cannot receive now");
+        return -1;
+    }
+
+    vmxnet3_rxpkt_init(&pkt);
+    mdata = vmxnet3_rxpkt_get_mdata(&pkt);
+
+    if (s->peer_has_vhdr) {
+        buf += sizeof(struct virtio_net_hdr);
+        size -= sizeof(struct virtio_net_hdr);
+        *vmxnet3_rxpkt_get_vhdr(&pkt) = *(const struct virtio_net_hdr *) buf;
+        mdata->vhdr_valid = true;
+    } else {
+        mdata->vhdr_valid = false;
+    }
+
+    mdata->packet_type = get_eth_packet_type(PKT_GET_ETH_HDR(buf));
+
+    if (vmxnet3_rx_filter_may_indicate(s, buf, size, mdata->packet_type)) {
+        vmxnet3_rxpkt_attach_data(s, &pkt, buf, size);
+        bytes_indicated = vmxnet3_indicate_packet(s, &pkt) ? size : -1;
+        if (bytes_indicated < size) {
+            DPKPRINTF("RX: %lu of %lu bytes indicated", bytes_indicated, size);
+        }
+    } else {
+        DPKPRINTF("Packet dropped by RX filter");
+        bytes_indicated = size;
+    }
+
+    assert(size > 0);
+    assert(bytes_indicated != 0);
+    return bytes_indicated;
+}
+
+static void vmxnet3_cleanup(VLANClientState *nc)
+{
+    VMXNET3_State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+    s->nic = NULL;
+}
+
+static void vmxnet3_set_link_status(VLANClientState *nc)
+{
+    VMXNET3_State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+
+    if (nc->link_down) {
+        s->link_status_and_speed &= ~VMXNET3_LINK_STATUS_UP;
+    } else {
+        s->link_status_and_speed |= VMXNET3_LINK_STATUS_UP;
+    }
+
+    vmxnet3_set_events(s, VMXNET3_ECR_LINK);
+    vmxnet3_trigger_interrupt(s, s->event_int_idx);
+}
+
+static NetClientInfo net_vmxnet3_info = {
+        .type = NET_CLIENT_TYPE_NIC,
+        .size = sizeof(NICState),
+        .can_receive = vmxnet3_can_receive,
+        .receive = vmxnet3_receive,
+        .cleanup = vmxnet3_cleanup,
+        .link_status_changed = vmxnet3_set_link_status,
+};
+
+static bool vmxnet3_peer_has_vnet_hdr(VMXNET3_State *s)
+{
+    VLANClientState *peer = s->nic->nc.peer;
+
+    if ((NULL != peer)                              &&
+        (NET_CLIENT_TYPE_TAP == peer->info->type)   &&
+        tap_has_vnet_hdr(peer)) {
+        return true;
+    }
+
+    DWRPRINTF("Peer has no virtio extension. Task offloads will not work.");
+    return false;
+}
+
+static void vmxnet3_net_uninit(VMXNET3_State *s)
+{
+    if (NULL != s->mcast_list) {
+        g_free(s->mcast_list);
+    }
+
+    vmxnet3_txpkt_cleanup(&s->curr_txpkt);
+}
+
+static void vmxnet3_net_init(VMXNET3_State *s)
+{
+    DCBPRINTF("vmxnet3_net_init called...");
+
+    vmxnet3_txpkt_init(&s->curr_txpkt);
+
+    qemu_macaddr_default_if_unset(&s->conf.macaddr);
+
+    /* Windows guest will query the address that was set on init */
+    memcpy(&s->perm_mac.a, &s->conf.macaddr.a, sizeof(s->perm_mac.a));
+
+    s->mcast_list = NULL;
+    s->mcast_list_len = 0;
+
+    s->link_status_and_speed = VMXNET3_LINK_SPEED | VMXNET3_LINK_STATUS_UP;
+
+    DCFPRINTF("Permanent MAC: " MAC_FMT, MAC_ARG(s->perm_mac.a));
+
+    s->nic = qemu_new_nic(&net_vmxnet3_info, &s->conf,
+                          object_get_typename(OBJECT(s)),
+                          s->dev.qdev.id, s);
+
+    s->peer_has_vhdr = vmxnet3_peer_has_vnet_hdr(s);
+    s->curr_txpkt_pl_frags = 0;
+    s->curr_txpkt_skip = false;
+    s->curr_txpkt_header_processed = false;
+
+    if (s->peer_has_vhdr) {
+        tap_set_vnet_hdr_len(s->nic->nc.peer, sizeof(struct virtio_net_hdr));
+        tap_using_vnet_hdr(s->nic->nc.peer, 1);
+    }
+
+    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
+}
+
+#ifdef VMXNET3_ENABLE_MSIX
+
+static void
+vmxnet3_unuse_msix_vectors(VMXNET3_State *s, int num_vectors)
+{
+    int i;
+    for (i = 0; i < num_vectors; i++) {
+        msix_vector_unuse(&s->dev, i);
+    }
+}
+
+static bool
+vmxnet3_use_msix_vectors(VMXNET3_State *s, int num_vectors)
+{
+    int i;
+    for (i = 0; i < num_vectors; i++) {
+        int res = msix_vector_use(&s->dev, i);
+        if (0 > res) {
+            DWRPRINTF("Failed to use MSI-X vector %d, error %d", i, res);
+            vmxnet3_unuse_msix_vectors(s, i);
+            return false;
+        }
+    }
+    return true;
+}
+
+static bool
+vmxnet3_init_msix(VMXNET3_State *s)
+{
+    int res = msix_init(&s->dev, VMXNET3_MAX_INTRS,
+                        &s->msix_bar, VMXNET3_MSIX_BAR_IDX, 0);
+    if (0 > res) {
+        DWRPRINTF("Failed to initialize MSI-X, error %d", res);
+        s->msix_used = false;
+    } else {
+        if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {
+            DWRPRINTF("Failed to use MSI-X vectors, error %d", res);
+            msix_uninit(&s->dev, &s->msix_bar);
+            s->msix_used = false;
+        } else {
+            s->msix_used = true;
+        }
+    }
+    return s->msix_used;
+}
+
+static void
+vmxnet3_cleanup_msix(VMXNET3_State *s)
+{
+    if (s->msix_used) {
+        msix_vector_unuse(&s->dev, VMXNET3_MAX_INTRS);
+        msix_uninit(&s->dev, &s->msix_bar);
+    }
+}
+#endif
+
+#ifdef VMXNET3_ENABLE_MSI
+
+static bool
+vmxnet3_init_msi(VMXNET3_State *s)
+{
+#define VMXNET3_MSI_NUM_VECTORS   (1)
+#define VMXNET3_MSI_OFFSET        (0x50)
+#define VMXNET3_USE_64BIT         (true)
+#define VMXNET3_PER_VECTOR_MASK   (false)
+
+    int res;
+    res = msi_init(&s->dev, VMXNET3_MSI_OFFSET, VMXNET3_MSI_NUM_VECTORS,
+                   VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK);
+    if (0 > res) {
+        DWRPRINTF("Failed to initialize MSI, error %d", res);
+        s->msi_used = false;
+    } else {
+        s->msi_used = true;
+    }
+
+    return s->msi_used;
+}
+
+static void
+vmxnet3_cleanup_msi(VMXNET3_State *s)
+{
+    if (s->msi_used) {
+        msi_uninit(&s->dev);
+    }
+}
+#endif
+
+static int vmxnet3_pci_init(PCIDevice *dev)
+{
+    static const MemoryRegionOps b0_ops = {
+        .read = vmxnet3_io_bar0_read,
+        .write = vmxnet3_io_bar0_write,
+        .endianness = DEVICE_LITTLE_ENDIAN,
+        .impl = {
+                .min_access_size = 4,
+                .max_access_size = 4,
+        },
+    };
+
+    static const MemoryRegionOps b1_ops = {
+        .read = vmxnet3_io_bar1_read,
+        .write = vmxnet3_io_bar1_write,
+        .endianness = DEVICE_LITTLE_ENDIAN,
+        .impl = {
+                .min_access_size = 4,
+                .max_access_size = 4,
+        },
+    };
+
+    VMXNET3_State *s = DO_UPCAST(VMXNET3_State, dev, dev);
+    int i;
+
+    DCBPRINTF("Starting init...");
+
+    memory_region_init_io(&s->bar0, &b0_ops, s,
+                          "vmxnet3-b0", VMXNET3_PT_REG_SIZE);
+    pci_register_bar(&s->dev, VMXNET3_BAR0_IDX,
+                     PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar0);
+
+    memory_region_init_io(&s->bar1, &b1_ops, s,
+                          "vmxnet3-b1", VMXNET3_VD_REG_SIZE);
+    pci_register_bar(&s->dev, VMXNET3_BAR1_IDX,
+                     PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar1);
+
+    memory_region_init(&s->msix_bar, "vmxnet3-msix-bar",
+                       VMXNET3_MSIX_BAR_SIZE);
+    pci_register_bar(&s->dev, VMXNET3_MSIX_BAR_IDX,
+                     PCI_BASE_ADDRESS_SPACE_MEMORY, &s->msix_bar);
+
+    for (i = 0; i < ARRAY_SIZE(s->interrupt_states); i++) {
+        s->interrupt_states[i].is_asserted = false;
+        s->interrupt_states[i].is_pending = false;
+        s->interrupt_states[i].is_masked = true;
+    }
+
+    /* Interrupt pin A */
+    s->dev.config[PCI_INTERRUPT_PIN] = 0x01;
+
+#ifdef VMXNET3_ENABLE_MSIX
+    if (!vmxnet3_init_msix(s)) {
+        hw_error("Failed to initialize MSI-X, configuration is inconsistent.");
+    }
+#endif
+
+#ifdef VMXNET3_ENABLE_MSI
+    if (!vmxnet3_init_msi(s)) {
+        hw_error("Failed to initialize MSI, configuration is inconsistent.");
+    }
+#endif
+
+    vmxnet3_net_init(s);
+    add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet-phy@0");
+
+    return 0;
+}
+
+
+static int vmxnet3_pci_uninit(PCIDevice *dev)
+{
+    VMXNET3_State *s = DO_UPCAST(VMXNET3_State, dev, dev);
+
+    DCBPRINTF("Starting uninit...");
+
+    vmxnet3_net_uninit(s);
+
+#ifdef VMXNET3_ENABLE_MSIX
+    vmxnet3_cleanup_msix(s);
+#endif
+
+#ifdef VMXNET3_ENABLE_MSI
+    vmxnet3_cleanup_msi(s);
+#endif
+
+    memory_region_destroy(&s->bar0);
+    memory_region_destroy(&s->bar1);
+    memory_region_destroy(&s->msix_bar);
+
+    return 0;
+}
+
+static void vmxnet3_qdev_reset(DeviceState *dev)
+{
+    VMXNET3_State *s = DO_UPCAST(VMXNET3_State, dev.qdev, dev);
+    DCBPRINTF("Starting QDEV reset...");
+    vmxnet3_reset(s);
+}
+
+static const VMStateDescription vmstate_vmxnet3 = {
+    .name = "vmxnet3",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+            VMSTATE_PCI_DEVICE(dev, VMXNET3_State),
+            VMSTATE_END_OF_LIST()
+    }
+};
+
+#if defined(VMXNET3_ENABLE_MSI) || defined(VMXNET3_ENABLE_MSIX)
+static void
+vmxnet3_write_config(PCIDevice *pci, uint32_t addr, uint32_t val, int len)
+{
+    pci_default_write_config(pci, addr, val, len);
+#if defined(VMXNET3_ENABLE_MSIX)
+    msix_write_config(pci, addr, val, len);
+#endif
+#if defined(VMXNET3_ENABLE_MSI)
+    msi_write_config(pci, addr, val, len);
+#endif
+}
+#endif
+
+static Property vmxnet3_properties[] = {
+    DEFINE_NIC_PROPERTIES(VMXNET3_State, conf),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vmxnet3_class_init(ObjectClass *class, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(class);
+    PCIDeviceClass *c = PCI_DEVICE_CLASS(class);
+
+    c->init = vmxnet3_pci_init;
+    c->exit = vmxnet3_pci_uninit;
+    c->romfile = "pxe-e1000.rom";
+    c->vendor_id = PCI_VENDOR_ID_VMWARE;
+    c->device_id = PCI_DEVICE_ID_VMWARE_VMXNET3;
+    c->revision = PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION;
+    c->class_id = PCI_CLASS_NETWORK_ETHERNET;
+    c->subsystem_vendor_id = PCI_VENDOR_ID_VMWARE;
+    c->subsystem_id = PCI_DEVICE_ID_VMWARE_VMXNET3;
+#if defined(VMXNET3_ENABLE_MSI) || defined(VMXNET3_ENABLE_MSIX)
+    c->config_write = vmxnet3_write_config,
+#endif
+    dc->desc = "VMWare Paravirtualized Ethernet v3";
+    dc->reset = vmxnet3_qdev_reset;
+    dc->vmsd = &vmstate_vmxnet3;
+    dc->props = vmxnet3_properties;
+}
+
+static TypeInfo vmxnet3_info = {
+    .name          = "vmxnet3",
+    .parent        = TYPE_PCI_DEVICE,
+    .instance_size = sizeof(VMXNET3_State),
+    .class_init    = vmxnet3_class_init,
+};
+
+static void vmxnet3_register_types(void)
+{
+    DCBPRINTF("vmxnet3_register_types called...");
+    type_register_static(&vmxnet3_info);
+}
+
+type_init(vmxnet3_register_types)
diff --git a/qemu/hw/vmxnet3.h b/qemu/hw/vmxnet3.h
new file mode 100644
index 0000000..6ec3fd5
--- /dev/null
+++ b/qemu/hw/vmxnet3.h
@@ -0,0 +1,727 @@
+/*
+ * QEMU VMWARE VMXNET3 paravirtual NIC
+ *
+ * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
+ *
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
+ *
+ * Authors:
+ * Dmitry Fleytman <dmitry@daynix.com>
+ * Yan Vugenfirer <yan@daynix.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef _QEMU_VMXNET3_H
+#define _QEMU_VMXNET3_H
+
+#define VMXNET3_DEVICE_MAX_TX_QUEUES 8
+#define VMXNET3_DEVICE_MAX_RX_QUEUES 8   /* Keep this value as a power of 2 */
+
+/* Defines needed to integrate VMWARE headers */
+#define u64     uint64_t
+#define u32     uint32_t
+#define u16     uint16_t
+#define u8      uint8_t
+#define __le16  uint16_t
+#define __le32  uint32_t
+#define __le64  uint64_t
+#define __packed QEMU_PACKED
+
+#if defined(HOST_WORDS_BIGENDIAN)
+#define const_cpu_to_le64(x) bswap_64(x)
+#define __BIG_ENDIAN_BITFIELD
+#else
+#define const_cpu_to_le64(x) (x)
+#endif
+
+/* Following is an interface definition for */
+/* VMXNET3 device as provided by VMWARE     */
+/* Original file and copyright is available */
+/* in Linux kernel v3.2.8 at                */
+/* drivers/net/vmxnet3/vmxnet3_defs.h       */
+
+struct UPT1_TxStats {
+    u64            TSOPktsTxOK;  /* TSO pkts post-segmentation */
+    u64            TSOBytesTxOK;
+    u64            ucastPktsTxOK;
+    u64            ucastBytesTxOK;
+    u64            mcastPktsTxOK;
+    u64            mcastBytesTxOK;
+    u64            bcastPktsTxOK;
+    u64            bcastBytesTxOK;
+    u64            pktsTxError;
+    u64            pktsTxDiscard;
+};
+
+struct UPT1_RxStats {
+    u64            LROPktsRxOK;    /* LRO pkts */
+    u64            LROBytesRxOK;   /* bytes from LRO pkts */
+    /* the following counters are for pkts from the wire, i.e., pre-LRO */
+    u64            ucastPktsRxOK;
+    u64            ucastBytesRxOK;
+    u64            mcastPktsRxOK;
+    u64            mcastBytesRxOK;
+    u64            bcastPktsRxOK;
+    u64            bcastBytesRxOK;
+    u64            pktsRxOutOfBuf;
+    u64            pktsRxError;
+};
+
+/* interrupt moderation level */
+enum {
+    UPT1_IML_NONE        = 0, /* no interrupt moderation */
+    UPT1_IML_HIGHEST    = 7, /* least intr generated */
+    UPT1_IML_ADAPTIVE    = 8, /* adpative intr moderation */
+};
+/* values for UPT1_RSSConf.hashFunc */
+enum {
+    UPT1_RSS_HASH_TYPE_NONE      = 0x0,
+    UPT1_RSS_HASH_TYPE_IPV4      = 0x01,
+    UPT1_RSS_HASH_TYPE_TCP_IPV4  = 0x02,
+    UPT1_RSS_HASH_TYPE_IPV6      = 0x04,
+    UPT1_RSS_HASH_TYPE_TCP_IPV6  = 0x08,
+};
+
+enum {
+    UPT1_RSS_HASH_FUNC_NONE      = 0x0,
+    UPT1_RSS_HASH_FUNC_TOEPLITZ  = 0x01,
+};
+
+#define UPT1_RSS_MAX_KEY_SIZE        40
+#define UPT1_RSS_MAX_IND_TABLE_SIZE  128
+
+struct UPT1_RSSConf {
+    u16            hashType;
+    u16            hashFunc;
+    u16            hashKeySize;
+    u16            indTableSize;
+    u8            hashKey[UPT1_RSS_MAX_KEY_SIZE];
+    u8            indTable[UPT1_RSS_MAX_IND_TABLE_SIZE];
+};
+
+/* features */
+enum {
+    UPT1_F_RXCSUM     = const_cpu_to_le64(0x0001), /* rx csum verification */
+    UPT1_F_RSS        = const_cpu_to_le64(0x0002),
+    UPT1_F_RXVLAN     = const_cpu_to_le64(0x0004), /* VLAN tag stripping */
+    UPT1_F_LRO        = const_cpu_to_le64(0x0008),
+};
+
+/* all registers are 32 bit wide */
+/* BAR 1 */
+enum {
+    VMXNET3_REG_VRRS    = 0x0,    /* Vmxnet3 Revision Report Selection */
+    VMXNET3_REG_UVRS    = 0x8,    /* UPT Version Report Selection */
+    VMXNET3_REG_DSAL    = 0x10,    /* Driver Shared Address Low */
+    VMXNET3_REG_DSAH    = 0x18,    /* Driver Shared Address High */
+    VMXNET3_REG_CMD        = 0x20,    /* Command */
+    VMXNET3_REG_MACL    = 0x28,    /* MAC Address Low */
+    VMXNET3_REG_MACH    = 0x30,    /* MAC Address High */
+    VMXNET3_REG_ICR        = 0x38,    /* Interrupt Cause Register */
+    VMXNET3_REG_ECR        = 0x40    /* Event Cause Register */
+};
+
+/* BAR 0 */
+enum {
+    VMXNET3_REG_IMR        = 0x0,     /* Interrupt Mask Register */
+    VMXNET3_REG_TXPROD    = 0x600, /* Tx Producer Index */
+    VMXNET3_REG_RXPROD    = 0x800, /* Rx Producer Index for ring 1 */
+    VMXNET3_REG_RXPROD2    = 0xA00     /* Rx Producer Index for ring 2 */
+};
+
+#define VMXNET3_PT_REG_SIZE     4096    /* BAR 0 */
+#define VMXNET3_VD_REG_SIZE     4096    /* BAR 1 */
+
+#define VMXNET3_REG_ALIGN       8    /* All registers are 8-byte aligned. */
+#define VMXNET3_REG_ALIGN_MASK  0x7
+
+/* I/O Mapped access to registers */
+#define VMXNET3_IO_TYPE_PT              0
+#define VMXNET3_IO_TYPE_VD              1
+#define VMXNET3_IO_ADDR(type, reg)      (((type) << 24) | ((reg) & 0xFFFFFF))
+#define VMXNET3_IO_TYPE(addr)           ((addr) >> 24)
+#define VMXNET3_IO_REG(addr)            ((addr) & 0xFFFFFF)
+
+enum {
+    VMXNET3_CMD_FIRST_SET = 0xCAFE0000,
+    VMXNET3_CMD_ACTIVATE_DEV = VMXNET3_CMD_FIRST_SET, /* 0xCAFE0000 */
+    VMXNET3_CMD_QUIESCE_DEV,                          /* 0xCAFE0001 */
+    VMXNET3_CMD_RESET_DEV,                            /* 0xCAFE0002 */
+    VMXNET3_CMD_UPDATE_RX_MODE,                       /* 0xCAFE0003 */
+    VMXNET3_CMD_UPDATE_MAC_FILTERS,                   /* 0xCAFE0004 */
+    VMXNET3_CMD_UPDATE_VLAN_FILTERS,                  /* 0xCAFE0005 */
+    VMXNET3_CMD_UPDATE_RSSIDT,                        /* 0xCAFE0006 */
+    VMXNET3_CMD_UPDATE_IML,                           /* 0xCAFE0007 */
+    VMXNET3_CMD_UPDATE_PMCFG,                         /* 0xCAFE0008 */
+    VMXNET3_CMD_UPDATE_FEATURE,                       /* 0xCAFE0009 */
+    VMXNET3_CMD_LOAD_PLUGIN,                          /* 0xCAFE000A */
+
+    VMXNET3_CMD_FIRST_GET = 0xF00D0000,
+    VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET, /* 0xF00D0000 */
+    VMXNET3_CMD_GET_STATS,                                /* 0xF00D0001 */
+    VMXNET3_CMD_GET_LINK,                                 /* 0xF00D0002 */
+    VMXNET3_CMD_GET_PERM_MAC_LO,                          /* 0xF00D0003 */
+    VMXNET3_CMD_GET_PERM_MAC_HI,                          /* 0xF00D0004 */
+    VMXNET3_CMD_GET_DID_LO,                               /* 0xF00D0005 */
+    VMXNET3_CMD_GET_DID_HI,                               /* 0xF00D0006 */
+    VMXNET3_CMD_GET_DEV_EXTRA_INFO,                       /* 0xF00D0007 */
+    VMXNET3_CMD_GET_CONF_INTR                             /* 0xF00D0008 */
+};
+
+/*
+ *    Little Endian layout of bitfields -
+ *    Byte 0 :    7.....len.....0
+ *    Byte 1 :    rsvd gen 13.len.8
+ *    Byte 2 :     5.msscof.0 ext1  dtype
+ *    Byte 3 :     13...msscof...6
+ *
+ *    Big Endian layout of bitfields -
+ *    Byte 0:        13...msscof...6
+ *    Byte 1 :     5.msscof.0 ext1  dtype
+ *    Byte 2 :    rsvd gen 13.len.8
+ *    Byte 3 :    7.....len.....0
+ *
+ *    Thus, le32_to_cpu on the dword will allow the big endian driver to read
+ *    the bit fields correctly. And cpu_to_le32 will convert bitfields
+ *    bit fields written by big endian driver to format required by device.
+ */
+
+struct Vmxnet3_TxDesc {
+    __le64 addr;
+
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32 msscof:14;  /* MSS, checksum offset, flags */
+    u32 ext1:1;
+    u32 dtype:1;    /* descriptor type */
+    u32 rsvd:1;
+    u32 gen:1;      /* generation bit */
+    u32 len:14;
+#else
+    u32 len:14;
+    u32 gen:1;      /* generation bit */
+    u32 rsvd:1;
+    u32 dtype:1;    /* descriptor type */
+    u32 ext1:1;
+    u32 msscof:14;  /* MSS, checksum offset, flags */
+#endif  /* __BIG_ENDIAN_BITFIELD */
+
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32 tci:16;     /* Tag to Insert */
+    u32 ti:1;       /* VLAN Tag Insertion */
+    u32 ext2:1;
+    u32 cq:1;       /* completion request */
+    u32 eop:1;      /* End Of Packet */
+    u32 om:2;       /* offload mode */
+    u32 hlen:10;    /* header len */
+#else
+    u32 hlen:10;    /* header len */
+    u32 om:2;       /* offload mode */
+    u32 eop:1;      /* End Of Packet */
+    u32 cq:1;       /* completion request */
+    u32 ext2:1;
+    u32 ti:1;       /* VLAN Tag Insertion */
+    u32 tci:16;     /* Tag to Insert */
+#endif  /* __BIG_ENDIAN_BITFIELD */
+};
+
+/* TxDesc.OM values */
+#define VMXNET3_OM_NONE        0
+#define VMXNET3_OM_CSUM        2
+#define VMXNET3_OM_TSO        3
+
+/* fields in TxDesc we access w/o using bit fields */
+#define VMXNET3_TXD_EOP_SHIFT    12
+#define VMXNET3_TXD_CQ_SHIFT    13
+#define VMXNET3_TXD_GEN_SHIFT    14
+#define VMXNET3_TXD_EOP_DWORD_SHIFT 3
+#define VMXNET3_TXD_GEN_DWORD_SHIFT 2
+
+#define VMXNET3_TXD_CQ        (1 << VMXNET3_TXD_CQ_SHIFT)
+#define VMXNET3_TXD_EOP        (1 << VMXNET3_TXD_EOP_SHIFT)
+#define VMXNET3_TXD_GEN        (1 << VMXNET3_TXD_GEN_SHIFT)
+
+#define VMXNET3_HDR_COPY_SIZE   128
+
+
+struct Vmxnet3_TxDataDesc {
+    u8        data[VMXNET3_HDR_COPY_SIZE];
+};
+
+#define VMXNET3_TCD_GEN_SHIFT    31
+#define VMXNET3_TCD_GEN_SIZE    1
+#define VMXNET3_TCD_TXIDX_SHIFT    0
+#define VMXNET3_TCD_TXIDX_SIZE    12
+#define VMXNET3_TCD_GEN_DWORD_SHIFT    3
+
+struct Vmxnet3_TxCompDesc {
+    u32        txdIdx:12;    /* Index of the EOP TxDesc */
+    u32        ext1:20;
+
+    __le32        ext2;
+    __le32        ext3;
+
+    u32        rsvd:24;
+    u32        type:7;       /* completion type */
+    u32        gen:1;        /* generation bit */
+};
+
+struct Vmxnet3_RxDesc {
+    __le64        addr;
+
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32        gen:1;        /* Generation bit */
+    u32        rsvd:15;
+    u32        dtype:1;      /* Descriptor type */
+    u32        btype:1;      /* Buffer Type */
+    u32        len:14;
+#else
+    u32        len:14;
+    u32        btype:1;      /* Buffer Type */
+    u32        dtype:1;      /* Descriptor type */
+    u32        rsvd:15;
+    u32        gen:1;        /* Generation bit */
+#endif
+    u32        ext1;
+};
+
+/* values of RXD.BTYPE */
+#define VMXNET3_RXD_BTYPE_HEAD   0    /* head only */
+#define VMXNET3_RXD_BTYPE_BODY   1    /* body only */
+
+/* fields in RxDesc we access w/o using bit fields */
+#define VMXNET3_RXD_BTYPE_SHIFT  14
+#define VMXNET3_RXD_GEN_SHIFT    31
+
+struct Vmxnet3_RxCompDesc {
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32        ext2:1;
+    u32        cnc:1;        /* Checksum Not Calculated */
+    u32        rssType:4;    /* RSS hash type used */
+    u32        rqID:10;      /* rx queue/ring ID */
+    u32        sop:1;        /* Start of Packet */
+    u32        eop:1;        /* End of Packet */
+    u32        ext1:2;
+    u32        rxdIdx:12;    /* Index of the RxDesc */
+#else
+    u32        rxdIdx:12;    /* Index of the RxDesc */
+    u32        ext1:2;
+    u32        eop:1;        /* End of Packet */
+    u32        sop:1;        /* Start of Packet */
+    u32        rqID:10;      /* rx queue/ring ID */
+    u32        rssType:4;    /* RSS hash type used */
+    u32        cnc:1;        /* Checksum Not Calculated */
+    u32        ext2:1;
+#endif  /* __BIG_ENDIAN_BITFIELD */
+
+    __le32        rssHash;      /* RSS hash value */
+
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32        tci:16;       /* Tag stripped */
+    u32        ts:1;         /* Tag is stripped */
+    u32        err:1;        /* Error */
+    u32        len:14;       /* data length */
+#else
+    u32        len:14;       /* data length */
+    u32        err:1;        /* Error */
+    u32        ts:1;         /* Tag is stripped */
+    u32        tci:16;       /* Tag stripped */
+#endif  /* __BIG_ENDIAN_BITFIELD */
+
+
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32        gen:1;        /* generation bit */
+    u32        type:7;       /* completion type */
+    u32        fcs:1;        /* Frame CRC correct */
+    u32        frg:1;        /* IP Fragment */
+    u32        v4:1;         /* IPv4 */
+    u32        v6:1;         /* IPv6 */
+    u32        ipc:1;        /* IP Checksum Correct */
+    u32        tcp:1;        /* TCP packet */
+    u32        udp:1;        /* UDP packet */
+    u32        tuc:1;        /* TCP/UDP Checksum Correct */
+    u32        csum:16;
+#else
+    u32        csum:16;
+    u32        tuc:1;        /* TCP/UDP Checksum Correct */
+    u32        udp:1;        /* UDP packet */
+    u32        tcp:1;        /* TCP packet */
+    u32        ipc:1;        /* IP Checksum Correct */
+    u32        v6:1;         /* IPv6 */
+    u32        v4:1;         /* IPv4 */
+    u32        frg:1;        /* IP Fragment */
+    u32        fcs:1;        /* Frame CRC correct */
+    u32        type:7;       /* completion type */
+    u32        gen:1;        /* generation bit */
+#endif  /* __BIG_ENDIAN_BITFIELD */
+};
+
+/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */
+#define VMXNET3_RCD_TUC_SHIFT    16
+#define VMXNET3_RCD_IPC_SHIFT    19
+
+/* fields in RxCompDesc we access via Vmxnet3_GenericDesc.qword[1] */
+#define VMXNET3_RCD_TYPE_SHIFT    56
+#define VMXNET3_RCD_GEN_SHIFT    63
+
+/* csum OK for TCP/UDP pkts over IP */
+#define VMXNET3_RCD_CSUM_OK (1 << VMXNET3_RCD_TUC_SHIFT | \
+                     1 << VMXNET3_RCD_IPC_SHIFT)
+#define VMXNET3_TXD_GEN_SIZE 1
+#define VMXNET3_TXD_EOP_SIZE 1
+
+/* value of RxCompDesc.rssType */
+enum {
+    VMXNET3_RCD_RSS_TYPE_NONE     = 0,
+    VMXNET3_RCD_RSS_TYPE_IPV4     = 1,
+    VMXNET3_RCD_RSS_TYPE_TCPIPV4  = 2,
+    VMXNET3_RCD_RSS_TYPE_IPV6     = 3,
+    VMXNET3_RCD_RSS_TYPE_TCPIPV6  = 4,
+};
+
+
+/* a union for accessing all cmd/completion descriptors */
+union Vmxnet3_GenericDesc {
+    __le64                qword[2];
+    __le32                dword[4];
+    __le16                word[8];
+    struct Vmxnet3_TxDesc        txd;
+    struct Vmxnet3_RxDesc        rxd;
+    struct Vmxnet3_TxCompDesc    tcd;
+    struct Vmxnet3_RxCompDesc    rcd;
+};
+
+#define VMXNET3_INIT_GEN       1
+
+/* Max size of a single tx buffer */
+#define VMXNET3_MAX_TX_BUF_SIZE  (1 << 14)
+
+/* # of tx desc needed for a tx buffer size */
+#define VMXNET3_TXD_NEEDED(size) (((size) + VMXNET3_MAX_TX_BUF_SIZE - 1) / \
+                    VMXNET3_MAX_TX_BUF_SIZE)
+
+/* max # of tx descs for a non-tso pkt */
+#define VMXNET3_MAX_TXD_PER_PKT 16
+
+/* Max size of a single rx buffer */
+#define VMXNET3_MAX_RX_BUF_SIZE  ((1 << 14) - 1)
+/* Minimum size of a type 0 buffer */
+#define VMXNET3_MIN_T0_BUF_SIZE  128
+#define VMXNET3_MAX_CSUM_OFFSET  1024
+
+/* Ring base address alignment */
+#define VMXNET3_RING_BA_ALIGN   512
+#define VMXNET3_RING_BA_MASK    (VMXNET3_RING_BA_ALIGN - 1)
+
+/* Ring size must be a multiple of 32 */
+#define VMXNET3_RING_SIZE_ALIGN 32
+#define VMXNET3_RING_SIZE_MASK  (VMXNET3_RING_SIZE_ALIGN - 1)
+
+/* Max ring size */
+#define VMXNET3_TX_RING_MAX_SIZE   4096
+#define VMXNET3_TC_RING_MAX_SIZE   4096
+#define VMXNET3_RX_RING_MAX_SIZE   4096
+#define VMXNET3_RC_RING_MAX_SIZE   8192
+
+/* a list of reasons for queue stop */
+
+enum {
+ VMXNET3_ERR_NOEOP        = 0x80000000, /* cannot find the EOP desc of a pkt */
+ VMXNET3_ERR_TXD_REUSE    = 0x80000001, /* reuse TxDesc before tx completion */
+ VMXNET3_ERR_BIG_PKT      = 0x80000002, /* too many TxDesc for a pkt */
+ VMXNET3_ERR_DESC_NOT_SPT = 0x80000003, /* descriptor type not supported */
+ VMXNET3_ERR_SMALL_BUF    = 0x80000004, /* type 0 buffer too small */
+ VMXNET3_ERR_STRESS       = 0x80000005, /* stress option firing in vmkernel */
+ VMXNET3_ERR_SWITCH       = 0x80000006, /* mode switch failure */
+ VMXNET3_ERR_TXD_INVALID  = 0x80000007, /* invalid TxDesc */
+};
+
+/* completion descriptor types */
+#define VMXNET3_CDTYPE_TXCOMP      0    /* Tx Completion Descriptor */
+#define VMXNET3_CDTYPE_RXCOMP      3    /* Rx Completion Descriptor */
+
+enum {
+    VMXNET3_GOS_BITS_UNK    = 0,   /* unknown */
+    VMXNET3_GOS_BITS_32     = 1,
+    VMXNET3_GOS_BITS_64     = 2,
+};
+
+#define VMXNET3_GOS_TYPE_UNK        0 /* unknown */
+#define VMXNET3_GOS_TYPE_LINUX      1
+#define VMXNET3_GOS_TYPE_WIN        2
+#define VMXNET3_GOS_TYPE_SOLARIS    3
+#define VMXNET3_GOS_TYPE_FREEBSD    4
+#define VMXNET3_GOS_TYPE_PXE        5
+
+struct Vmxnet3_GOSInfo {
+#ifdef __BIG_ENDIAN_BITFIELD
+    u32        gosMisc:10;    /* other info about gos */
+    u32        gosVer:16;     /* gos version */
+    u32        gosType:4;     /* which guest */
+    u32        gosBits:2;    /* 32-bit or 64-bit? */
+#else
+    u32        gosBits:2;     /* 32-bit or 64-bit? */
+    u32        gosType:4;     /* which guest */
+    u32        gosVer:16;     /* gos version */
+    u32        gosMisc:10;    /* other info about gos */
+#endif  /* __BIG_ENDIAN_BITFIELD */
+};
+
+struct Vmxnet3_DriverInfo {
+    __le32                version;
+    struct Vmxnet3_GOSInfo        gos;
+    __le32                vmxnet3RevSpt;
+    __le32                uptVerSpt;
+};
+
+
+#define VMXNET3_REV1_MAGIC  0xbabefee1
+
+/*
+ * QueueDescPA must be 128 bytes aligned. It points to an array of
+ * Vmxnet3_TxQueueDesc followed by an array of Vmxnet3_RxQueueDesc.
+ * The number of Vmxnet3_TxQueueDesc/Vmxnet3_RxQueueDesc are specified by
+ * Vmxnet3_MiscConf.numTxQueues/numRxQueues, respectively.
+ */
+#define VMXNET3_QUEUE_DESC_ALIGN  128
+
+
+struct Vmxnet3_MiscConf {
+    struct Vmxnet3_DriverInfo driverInfo;
+    __le64        uptFeatures;
+    __le64        ddPA;         /* driver data PA */
+    __le64        queueDescPA;  /* queue descriptor table PA */
+    __le32        ddLen;        /* driver data len */
+    __le32        queueDescLen; /* queue desc. table len in bytes */
+    __le32        mtu;
+    __le16        maxNumRxSG;
+    u8        numTxQueues;
+    u8        numRxQueues;
+    __le32        reserved[4];
+};
+
+
+struct Vmxnet3_TxQueueConf {
+    __le64        txRingBasePA;
+    __le64        dataRingBasePA;
+    __le64        compRingBasePA;
+    __le64        ddPA;         /* driver data */
+    __le64        reserved;
+    __le32        txRingSize;   /* # of tx desc */
+    __le32        dataRingSize; /* # of data desc */
+    __le32        compRingSize; /* # of comp desc */
+    __le32        ddLen;        /* size of driver data */
+    u8        intrIdx;
+    u8        _pad[7];
+};
+
+
+struct Vmxnet3_RxQueueConf {
+    __le64        rxRingBasePA[2];
+    __le64        compRingBasePA;
+    __le64        ddPA;            /* driver data */
+    __le64        reserved;
+    __le32        rxRingSize[2];   /* # of rx desc */
+    __le32        compRingSize;    /* # of rx comp desc */
+    __le32        ddLen;           /* size of driver data */
+    u8        intrIdx;
+    u8        _pad[7];
+};
+
+
+enum vmxnet3_intr_mask_mode {
+    VMXNET3_IMM_AUTO   = 0,
+    VMXNET3_IMM_ACTIVE = 1,
+    VMXNET3_IMM_LAZY   = 2
+};
+
+enum vmxnet3_intr_type {
+    VMXNET3_IT_AUTO = 0,
+    VMXNET3_IT_INTX = 1,
+    VMXNET3_IT_MSI  = 2,
+    VMXNET3_IT_MSIX = 3
+};
+
+#define VMXNET3_MAX_TX_QUEUES  8
+#define VMXNET3_MAX_RX_QUEUES  16
+/* addition 1 for events */
+#define VMXNET3_MAX_INTRS      25
+
+/* value of intrCtrl */
+#define VMXNET3_IC_DISABLE_ALL  0x1   /* bit 0 */
+
+
+struct Vmxnet3_IntrConf {
+    bool        autoMask;
+    u8        numIntrs;      /* # of interrupts */
+    u8        eventIntrIdx;
+    u8        modLevels[VMXNET3_MAX_INTRS];    /* moderation level for
+                             * each intr */
+    __le32        intrCtrl;
+    __le32        reserved[2];
+};
+
+/* one bit per VLAN ID, the size is in the units of u32 */
+#define VMXNET3_VFT_SIZE  (4096/(sizeof(uint32_t)*8))
+
+
+struct Vmxnet3_QueueStatus {
+    bool        stopped;
+    u8        _pad[3];
+    __le32        error;
+};
+
+
+struct Vmxnet3_TxQueueCtrl {
+    __le32        txNumDeferred;
+    __le32        txThreshold;
+    __le64        reserved;
+};
+
+
+struct Vmxnet3_RxQueueCtrl {
+    bool        updateRxProd;
+    u8        _pad[7];
+    __le64        reserved;
+};
+
+enum {
+    VMXNET3_RXM_UCAST     = 0x01,  /* unicast only */
+    VMXNET3_RXM_MCAST     = 0x02,  /* multicast passing the filters */
+    VMXNET3_RXM_BCAST     = 0x04,  /* broadcast only */
+    VMXNET3_RXM_ALL_MULTI = 0x08,  /* all multicast */
+    VMXNET3_RXM_PROMISC   = 0x10  /* promiscuous */
+};
+
+struct Vmxnet3_RxFilterConf {
+    __le32        rxMode;       /* VMXNET3_RXM_xxx */
+    __le16        mfTableLen;   /* size of the multicast filter table */
+    __le16        _pad1;
+    __le64        mfTablePA;    /* PA of the multicast filters table */
+    __le32        vfTable[VMXNET3_VFT_SIZE]; /* vlan filter */
+};
+
+
+#define VMXNET3_PM_MAX_FILTERS        6
+#define VMXNET3_PM_MAX_PATTERN_SIZE   128
+#define VMXNET3_PM_MAX_MASK_SIZE      (VMXNET3_PM_MAX_PATTERN_SIZE / 8)
+
+#define VMXNET3_PM_WAKEUP_MAGIC  cpu_to_le16(0x01)  /* wake up on magic pkts */
+#define VMXNET3_PM_WAKEUP_FILTER cpu_to_le16(0x02)  /* wake up on pkts matching
+                                                     * filters */
+
+
+struct Vmxnet3_PM_PktFilter {
+    u8        maskSize;
+    u8        patternSize;
+    u8        mask[VMXNET3_PM_MAX_MASK_SIZE];
+    u8        pattern[VMXNET3_PM_MAX_PATTERN_SIZE];
+    u8        pad[6];
+};
+
+
+struct Vmxnet3_PMConf {
+    __le16        wakeUpEvents;  /* VMXNET3_PM_WAKEUP_xxx */
+    u8        numFilters;
+    u8        pad[5];
+    struct Vmxnet3_PM_PktFilter filters[VMXNET3_PM_MAX_FILTERS];
+};
+
+
+struct Vmxnet3_VariableLenConfDesc {
+    __le32        confVer;
+    __le32        confLen;
+    __le64        confPA;
+};
+
+
+struct Vmxnet3_TxQueueDesc {
+    struct Vmxnet3_TxQueueCtrl        ctrl;
+    struct Vmxnet3_TxQueueConf        conf;
+
+    /* Driver read after a GET command */
+    struct Vmxnet3_QueueStatus        status;
+    struct UPT1_TxStats            stats;
+    u8                    _pad[88]; /* 128 aligned */
+};
+
+
+struct Vmxnet3_RxQueueDesc {
+    struct Vmxnet3_RxQueueCtrl        ctrl;
+    struct Vmxnet3_RxQueueConf        conf;
+    /* Driver read after a GET commad */
+    struct Vmxnet3_QueueStatus        status;
+    struct UPT1_RxStats            stats;
+    u8                      __pad[88]; /* 128 aligned */
+};
+
+
+struct Vmxnet3_DSDevRead {
+    /* read-only region for device, read by dev in response to a SET cmd */
+    struct Vmxnet3_MiscConf            misc;
+    struct Vmxnet3_IntrConf            intrConf;
+    struct Vmxnet3_RxFilterConf        rxFilterConf;
+    struct Vmxnet3_VariableLenConfDesc    rssConfDesc;
+    struct Vmxnet3_VariableLenConfDesc    pmConfDesc;
+    struct Vmxnet3_VariableLenConfDesc    pluginConfDesc;
+};
+
+/* All structures in DriverShared are padded to multiples of 8 bytes */
+struct Vmxnet3_DriverShared {
+    __le32              magic;
+    /* make devRead start at 64bit boundaries */
+    __le32              pad;
+    struct Vmxnet3_DSDevRead    devRead;
+    __le32              ecr;
+    __le32              reserved[5];
+};
+
+
+#define VMXNET3_ECR_RQERR       (1 << 0)
+#define VMXNET3_ECR_TQERR       (1 << 1)
+#define VMXNET3_ECR_LINK        (1 << 2)
+#define VMXNET3_ECR_DIC         (1 << 3)
+#define VMXNET3_ECR_DEBUG       (1 << 4)
+
+/* flip the gen bit of a ring */
+#define VMXNET3_FLIP_RING_GEN(gen) ((gen) = (gen) ^ 0x1)
+
+/* only use this if moving the idx won't affect the gen bit */
+#define VMXNET3_INC_RING_IDX_ONLY(idx, ring_size) \
+    do {\
+        (idx)++;\
+        if (unlikely((idx) == (ring_size))) {\
+            (idx) = 0;\
+        } \
+    } while (0)
+
+#define VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid) \
+    (vfTable[vid >> 5] |= (1 << (vid & 31)))
+#define VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid) \
+    (vfTable[vid >> 5] &= ~(1 << (vid & 31)))
+
+#define VMXNET3_VFTABLE_ENTRY_IS_SET(vfTable, vid) \
+    ((vfTable[vid >> 5] & (1 << (vid & 31))) != 0)
+
+#define VMXNET3_MAX_MTU     9000
+#define VMXNET3_MIN_MTU     60
+
+#define VMXNET3_LINK_UP         (10000 << 16 | 1)    /* 10 Gbps, up */
+#define VMXNET3_LINK_DOWN       0
+
+#undef u64
+#undef u32
+#undef u16
+#undef u8
+#undef __le16
+#undef __le32
+#undef __le64
+#undef __packed
+#undef const_cpu_to_le64
+#if defined(HOST_WORDS_BIGENDIAN)
+#undef __BIG_ENDIAN_BITFIELD
+#endif
+
+#endif
diff --git a/qemu/hw/vmxnet3_debug.h b/qemu/hw/vmxnet3_debug.h
new file mode 100644
index 0000000..8383c22
--- /dev/null
+++ b/qemu/hw/vmxnet3_debug.h
@@ -0,0 +1,104 @@
+/*
+ * QEMU VMWARE VMXNET3 paravirtual NIC - debugging facilities
+ *
+ * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
+ *
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
+ *
+ * Authors:
+ * Dmitry Fleytman <dmitry@daynix.com>
+ * Yan Vugenfirer <yan@daynix.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef _QEMU_VMXNET3_DEBUG_H
+#define _QEMU_VMXNET3_DEBUG_H
+
+/* #define DEBUG_VMXNET3_CB */
+#define DEBUG_VMXNET3_WARNINGS
+#define DEBUG_VMXNET3_ERRORS
+/* #define DEBUG_VMXNET3_INTERRUPTS */
+/* #define DEBUG_VMXNET3_CONFIG */
+/*  #define DEBUG_VMXNET3_SHMEM_ACCESS */
+/* #define DEBUG_VMXNET3_RINGS */
+/* #define DEBUG_VMXNET3_PACKETS */
+
+#ifdef DEBUG_VMXNET3_SHMEM_ACCESS
+#define DSHPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][SH][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DSHPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_CB
+#define DCBPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][CB][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DCBPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_PACKETS
+#define DPKPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][PK][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DPKPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_WARNINGS
+#define DWRPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][WR][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DWRPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_ERRORS
+#define DERPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][ER][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DERPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_INTERRUPTS
+#define DIRPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][IR][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DIRPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_CONFIG
+#define DCFPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][CF][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DCFPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#ifdef DEBUG_VMXNET3_RINGS
+#define DRIPRINTF(fmt, ...)                                                   \
+    do {                                                                      \
+        printf("[vmxnet3][RI][%s]: " fmt "\n", __func__, ## __VA_ARGS__);     \
+    } while (0)
+#else
+#define DRIPRINTF(fmt, ...) do {} while (0)
+#endif
+
+#define MAC_FMT       "%02X:%02X:%02X:%02X:%02X:%02X"
+#define MAC_ARG(a)  (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+
+#endif /* _QEMU_VMXNET3_DEBUG_H  */
diff --git a/qemu/hw/vmxnet_utils.c b/qemu/hw/vmxnet_utils.c
new file mode 100644
index 0000000..e310828
--- /dev/null
+++ b/qemu/hw/vmxnet_utils.c
@@ -0,0 +1,172 @@
+/*
+ * QEMU VMWARE paravirtual devices - network auxiliary code
+ *
+ * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
+ *
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
+ *
+ * Authors:
+ * Dmitry Fleytman <dmitry@daynix.com>
+ * Yan Vugenfirer <yan@daynix.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "hw.h"
+#include "virtio-net.h"
+#include "vmxnet_utils.h"
+#include "net/checksum.h"
+
+void eth_setup_vlan_headers(struct eth_header *ehdr, uint16_t vlan_tag)
+{
+    switch (be16_to_cpu(ehdr->h_proto)) {
+    case ETH_P_VLAN:
+    case ETH_P_DVLAN: {
+        /* Header already present, just put proper VLAN tag */
+        struct vlan_header *vhdr = PKT_GET_VLAN_HDR(ehdr);
+        vhdr->h_tci = cpu_to_be16(vlan_tag);
+    }
+    default: {
+        /* No VLAN header, put a new one */
+        struct vlan_header *vhdr = PKT_GET_VLAN_HDR(ehdr);
+        vhdr->h_proto = ehdr->h_proto;
+        ehdr->h_proto = cpu_to_be16(ETH_P_VLAN);
+        vhdr->h_tci = cpu_to_be16(vlan_tag);
+    }
+    }
+}
+
+bool eth_setup_tx_offloads(uint8_t *l3hdr,
+                                      size_t l3hdr_len,
+                                      size_t l3hdr_off,
+                                      uint32_t l3payload_len,
+                                      struct virtio_net_hdr *vhdr,
+                                      bool more_frags,
+                                      uint16_t fragmentation_offset)
+{
+    uint16_t csum;
+
+    switch (vhdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
+    case VIRTIO_NET_HDR_GSO_TCPV4:
+    case VIRTIO_NET_HDR_GSO_UDP: {
+        struct ip_header *iphdr = (struct ip_header *) l3hdr;
+        uint16_t new_ip_off;
+
+        vhdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
+        vhdr->csum_start = l3hdr_off;
+        vhdr->csum_offset = offsetof(struct ip_header, ip_sum);
+
+        if (l3payload_len + l3hdr_len > ETH_MAX_IP_DGRAM_LEN) {
+            /* This must never happen with fragmentation enabled */
+            assert(0 == more_frags);
+            assert(0 == fragmentation_offset);
+            return false;
+        }
+
+        iphdr->ip_len = cpu_to_be16(l3payload_len + l3hdr_len);
+        assert(0 == (~IP_OFFMASK & fragmentation_offset));
+
+        new_ip_off = fragmentation_offset | (more_frags ? IP_MF : 0) |
+                        (be16_to_cpu(iphdr->ip_off) & ~(IP_OFFMASK|IP_MF));
+
+        iphdr->ip_off = cpu_to_be16(new_ip_off);
+
+        /* Due to Linux bridge bugs/features IP header checksum */
+        /* must be calculated in order to make it process       */
+        /* packet with segmentation requirements successfully   */
+        eth_put_csum(l3hdr, vhdr->csum_offset, 0);
+        csum = net_raw_checksum(l3hdr, l3hdr_len);
+        eth_put_csum(l3hdr, vhdr->csum_offset, csum);
+    }
+    break;
+
+    case VIRTIO_NET_HDR_GSO_TCPV6:
+    default:
+        vhdr->flags = 0;
+        break;
+    }
+
+    return true;
+}
+
+uint8_t
+eth_get_gso_type(uint16_t l3_proto, uint8_t *l3_hdr)
+{
+    uint8_t ecn_state = 0;
+
+    if (ETH_P_IP == l3_proto) {
+        struct ip_header *iphdr = (struct ip_header *) l3_hdr;
+
+        if (IP_HEADER_VERSION_4 == IP_HEADER_VERSION(iphdr)) {
+            if (IPTOS_ECN_CE == IPTOS_ECN(iphdr->ip_tos)) {
+                ecn_state = VIRTIO_NET_HDR_GSO_ECN;
+            }
+            if (IP_PROTO_TCP == iphdr->ip_p) {
+                return VIRTIO_NET_HDR_GSO_TCPV4 | ecn_state;
+            } else if (IP_PROTO_UDP == iphdr->ip_p) {
+                return VIRTIO_NET_HDR_GSO_UDP | ecn_state;
+            }
+        }
+    } else if (ETH_P_IPV6 == l3_proto) {
+        struct ip6_header *ip6hdr = (struct ip6_header *) l3_hdr;
+
+        if (IP6_ECN_CE == IP6_ECN(ip6hdr->ip6_ecn_acc)) {
+            ecn_state = VIRTIO_NET_HDR_GSO_ECN;
+        }
+
+        if (IP_PROTO_TCP == ip6hdr->ip6_nxt) {
+            return VIRTIO_NET_HDR_GSO_TCPV6 | ecn_state;
+        }
+    }
+
+    /* Unsupported offload */
+    assert(false);
+
+    return VIRTIO_NET_HDR_GSO_NONE | ecn_state;
+}
+
+void eth_get_protocols(const uint8_t *headers,
+                       uint32_t hdr_length,
+                       bool *isip4, bool *isip6,
+                       bool *isudp, bool *istcp)
+{
+    int proto;
+    size_t l2hdr_len = eth_get_l2_hdr_length(headers);
+    assert(hdr_length >= eth_get_l2_hdr_length(headers));
+    *isip4 = *isip6 = *isudp = *istcp = false;
+
+    proto = eth_get_l3_proto(headers, l2hdr_len);
+    if (ETH_P_IP == proto) {
+        *isip4 = true;
+
+        struct ip_header *iphdr;
+
+        assert(hdr_length >=
+            eth_get_l2_hdr_length(headers) + sizeof(struct ip_header));
+
+        iphdr = PKT_GET_IP_HDR(headers);
+
+        if (IP_HEADER_VERSION_4 == IP_HEADER_VERSION(iphdr)) {
+            if (IP_PROTO_TCP == iphdr->ip_p) {
+                *istcp = true;
+            } else if (IP_PROTO_UDP == iphdr->ip_p) {
+                *isudp = true;
+            }
+        }
+    } else if (ETH_P_IPV6 == proto) {
+        *isip6 = true;
+
+        struct ip6_header *ip6hdr;
+        assert(hdr_length >=
+            eth_get_l2_hdr_length(headers) + sizeof(struct ip6_header));
+        ip6hdr = PKT_GET_IP6_HDR(headers);
+
+        if (IP_PROTO_TCP == ip6hdr->ip6_nxt) {
+            *istcp = true;
+        } else if (IP_PROTO_UDP == ip6hdr->ip6_nxt) {
+            *isudp = true;
+        }
+    }
+}
diff --git a/qemu/hw/vmxnet_utils.h b/qemu/hw/vmxnet_utils.h
new file mode 100644
index 0000000..f5e79dd
--- /dev/null
+++ b/qemu/hw/vmxnet_utils.h
@@ -0,0 +1,242 @@
+/*
+ * QEMU VMWARE paravirtual devices - network auxiliary code
+ *
+ * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
+ *
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
+ *
+ * Authors:
+ * Dmitry Fleytman <dmitry@daynix.com>
+ * Yan Vugenfirer <yan@daynix.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#define ETH_ALEN    6
+
+struct eth_header {
+    uint8_t  h_dest[ETH_ALEN];   /* destination eth addr */
+    uint8_t  h_source[ETH_ALEN]; /* source ether addr    */
+    uint16_t h_proto;            /* packet type ID field */
+};
+
+struct vlan_header {
+    uint16_t  h_tci;     /* priority and VLAN ID  */
+    uint16_t  h_proto;   /* encapsulated protocol */
+};
+
+struct ip_header {
+    uint8_t  ip_ver_len;     /* version and header length */
+    uint8_t  ip_tos;         /* type of service */
+    uint16_t ip_len;         /* total length */
+    uint16_t ip_id;          /* identification */
+    uint16_t ip_off;         /* fragment offset field */
+    uint8_t  ip_ttl;         /* time to live */
+    uint8_t  ip_p;           /* protocol */
+    uint16_t ip_sum;         /* checksum */
+    uint32_t ip_src, ip_dst; /* source and dest address */
+};
+
+/* IPv6 address */
+struct in6_addr {
+    union {
+        uint8_t __u6_addr8[16];
+    } __in6_u;
+};
+
+struct ip6_header {
+    union {
+        struct ip6_hdrctl {
+            uint32_t ip6_un1_flow; /* 4 bits version, 8 bits TC,
+                                      20 bits flow-ID */
+            uint16_t ip6_un1_plen; /* payload length */
+            uint8_t  ip6_un1_nxt;  /* next header */
+            uint8_t  ip6_un1_hlim; /* hop limit */
+        } ip6_un1;
+        uint8_t ip6_un2_vfc;       /* 4 bits version, top 4 bits tclass */
+        struct ip6_ecn_access {
+            uint8_t  ip6_un3_vfc;  /* 4 bits version, top 4 bits tclass */
+            uint8_t  ip6_un3_ecn;  /* 2 bits ECN, top 6 bits payload length */
+        } ip6_un3;
+    } ip6_ctlun;
+    struct in6_addr ip6_src;     /* source address */
+    struct in6_addr ip6_dst;     /* destination address */
+};
+#define ip6_nxt      ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_ecn_acc  ip6_ctlun.ip6_un3.ip6_un3_ecn
+
+#define PKT_GET_ETH_HDR(p)        \
+    ((struct eth_header *)(p))
+#define PKT_GET_VLAN_HDR(p)       \
+    ((struct vlan_header *) (((uint8_t *)(p)) + sizeof(struct eth_header)))
+#define PKT_GET_IP_HDR(p)         \
+    ((struct ip_header *)(((uint8_t *)(p)) + eth_get_l2_hdr_length(p)))
+#define IP_HDR_GET_LEN(p)         \
+    ((((struct ip_header *)p)->ip_ver_len & 0x0F) << 2)
+#define PKT_GET_IP_HDR_LEN(p)     \
+    (IP_HDR_GET_LEN(PKT_GET_IP_HDR(p)))
+#define PKT_GET_IP6_HDR(p)        \
+    ((struct ip6_header *) (((uint8_t *)(p)) + eth_get_l2_hdr_length(p)))
+#define IP_HEADER_VERSION(ip)     \
+    ((ip->ip_ver_len >> 4)&0xf)
+
+#define ETH_P_IP                  (0x0800)
+#define ETH_P_IPV6                (0x86dd)
+#define ETH_P_VLAN                (0x8100)
+#define ETH_P_DVLAN               (0x88a8)
+#define VLAN_VID_MASK             0x0fff
+#define IP_HEADER_VERSION_4       (4)
+#define IP_HEADER_VERSION_6       (6)
+#define IP_PROTO_TCP              (6)
+#define IP_PROTO_UDP              (17)
+#define IPTOS_ECN_MASK            0x03
+#define IPTOS_ECN(x)              ((x) & IPTOS_ECN_MASK)
+#define IPTOS_ECN_CE              0x03
+#define IP6_ECN_MASK              0xC0
+#define IP6_ECN(x)                ((x) & IP6_ECN_MASK)
+#define IP6_ECN_CE                0xC0
+#define IP4_DONT_FRAGMENT_FLAG    (1 << 14)
+
+#define IS_SPECIAL_VLAN_ID(x)     \
+    ((0 == (x)) || (0xFFF == (x)))
+
+#define ETH_MAX_L2_HDR_LEN  \
+    (sizeof(struct eth_header) + 2*sizeof(struct vlan_header))
+
+#define ETH_MAX_IP4_HDR_LEN   (60)
+#define ETH_MAX_IP6_HDR_LEN   \
+    (sizeof(struct ip6_header))
+#define ETH_MAX_L3_HDR_LEN    \
+    (MAX(ETH_MAX_IP4_HDR_LEN, ETH_MAX_IP6_HDR_LEN))
+#define ETH_MAX_IP_DGRAM_LEN  (0xFFFF)
+#define ETH_MAX_IP_PLOAD_LEN  \
+    (ETH_MAX_IP_DGRAM_LEN - ETH_MAX_IP4_HDR_LEN - ETH_MAX_L2_HDR_LEN)
+
+#define IP_FRAG_UNIT_SIZE     (8)
+#define IP_FRAG_ALIGN_SIZE(x) ((x) & ~0x7)
+#define IP_RF                 0x8000           /* reserved fragment flag */
+#define IP_DF                 0x4000           /* don't fragment flag */
+#define IP_MF                 0x2000           /* more fragments flag */
+#define IP_OFFMASK            0x1fff           /* mask for fragmenting bits */
+
+
+static inline int is_multicast_ether_addr(const uint8_t *addr)
+{
+    return 0x01 & addr[0];
+}
+
+static inline int is_broadcast_ether_addr(const uint8_t *addr)
+{
+    return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff;
+}
+
+static inline int is_unicast_ether_addr(const uint8_t *addr)
+{
+    return !is_multicast_ether_addr(addr);
+}
+
+typedef enum {
+    VMXNET3_PKT_UCAST = 0xAABBCC00,
+    VMXNET3_PKT_BCAST,
+    VMXNET3_PKT_MCAST
+} eth_pkt_types_e;
+
+static inline eth_pkt_types_e
+get_eth_packet_type(const struct eth_header *ehdr)
+{
+    if (is_broadcast_ether_addr(ehdr->h_dest)) {
+        return VMXNET3_PKT_BCAST;
+    } else if (is_multicast_ether_addr(ehdr->h_dest)) {
+        return VMXNET3_PKT_MCAST;
+    } else { /* unicast */
+        return VMXNET3_PKT_UCAST;
+    }
+}
+
+static inline uint32_t
+eth_get_l2_hdr_length(const void *p)
+{
+    uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto);
+    struct vlan_header *hvlan = PKT_GET_VLAN_HDR(p);
+    switch (proto) {
+    case ETH_P_VLAN:
+        return sizeof(struct eth_header) + sizeof(struct vlan_header);
+    case ETH_P_DVLAN:
+        if (ETH_P_VLAN == hvlan->h_proto) {
+            return sizeof(struct eth_header) + 2*sizeof(struct vlan_header);
+        } else {
+            return sizeof(struct eth_header) + sizeof(struct vlan_header);
+        }
+    default:
+        return sizeof(struct eth_header);
+    }
+}
+
+static inline uint16_t
+eth_get_pkt_vlan_tag(const void *p)
+{
+    uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto);
+    struct vlan_header *hvlan = PKT_GET_VLAN_HDR(p);
+    switch (proto) {
+    case ETH_P_VLAN:
+    case ETH_P_DVLAN:
+        return be16_to_cpu(hvlan->h_proto);
+    default:
+        return 0;
+    }
+}
+
+static inline bool
+eth_strip_vlan(const void *p, struct eth_header *new_ehdr,
+                      uint16_t *payload_offset, uint16_t *vlan_tag)
+{
+    uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(p)->h_proto);
+    struct vlan_header *hvlan = PKT_GET_VLAN_HDR(p);
+
+    switch (proto) {
+    case ETH_P_VLAN:
+    case ETH_P_DVLAN:
+        memcpy(new_ehdr->h_source, PKT_GET_ETH_HDR(p)->h_source, ETH_ALEN);
+        memcpy(new_ehdr->h_dest, PKT_GET_ETH_HDR(p)->h_dest, ETH_ALEN);
+        new_ehdr->h_proto = hvlan->h_proto;
+        *vlan_tag = be16_to_cpu(hvlan->h_tci);
+        *payload_offset =
+            sizeof(struct eth_header) + sizeof(struct vlan_header);
+        return true;
+    default:
+        return false;
+    }
+}
+
+static inline uint16_t
+eth_get_l3_proto(const void *l2hdr, size_t l2hdr_len)
+{
+    uint8_t *proto_ptr = (uint8_t *) l2hdr + l2hdr_len - sizeof(uint16_t);
+    return be16_to_cpup((uint16_t *)proto_ptr);
+}
+
+static inline void
+eth_put_csum(uint8_t *buf, uint32_t cso, uint16_t csum)
+{
+    cpu_to_be16wu((uint16_t *)(buf + cso), csum);
+}
+
+void eth_setup_vlan_headers(struct eth_header *ehdr, uint16_t vlan_tag);
+
+
+bool eth_setup_tx_offloads(uint8_t *l3hdr,
+                                      size_t l3hdr_len,
+                                      size_t l3hdr_off,
+                                      uint32_t l3payload_len,
+                                      struct virtio_net_hdr *vhdr,
+                                      bool more_frags,
+                                      uint16_t fragmentation_offset);
+
+uint8_t eth_get_gso_type(uint16_t l3_proto, uint8_t *l3_hdr);
+
+void eth_get_protocols(const uint8_t *headers,
+                       uint32_t hdr_length,
+                       bool *isip4, bool *isip6,
+                       bool *isudp, bool *istcp);
diff --git a/qemu/net.c b/qemu/net.c
index c34474f..e2f586c 100644
--- a/qemu/net.c
+++ b/qemu/net.c
@@ -857,7 +857,7 @@ static const struct {
             }, {
                 .name = "model",
                 .type = QEMU_OPT_STRING,
-                .help = "device model (e1000, rtl8139, virtio etc.)",
+                .help = "device model (e1000, rtl8139, virtio, vmxnet3 etc.)",
             }, {
                 .name = "addr",
                 .type = QEMU_OPT_STRING,
diff --git a/qemu/net/checksum.h b/qemu/net/checksum.h
index 1f05298..5f42a02 100644
--- a/qemu/net/checksum.h
+++ b/qemu/net/checksum.h
@@ -26,4 +26,11 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
                              uint8_t *addrs, uint8_t *buf);
 void net_checksum_calculate(uint8_t *data, int length);
 
+static inline uint16_t
+net_raw_checksum(uint8_t *data, int length)
+{
+  return net_checksum_finish(net_checksum_add(length, data));
+}
+
+
 #endif /* QEMU_NET_CHECKSUM_H */
-- 
1.7.7.6

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

* [Qemu-devel] (no subject)
@ 2011-12-29 21:17 Fred Oliveira
  0 siblings, 0 replies; 133+ messages in thread
From: Fred Oliveira @ 2011-12-29 21:17 UTC (permalink / raw)
  To: qemu-devel



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

* Re: [Qemu-devel] (no subject)
  2011-12-13 15:22       ` Erik Lotspeich
@ 2011-12-13 15:56         ` Paolo Bonzini
  0 siblings, 0 replies; 133+ messages in thread
From: Paolo Bonzini @ 2011-12-13 15:56 UTC (permalink / raw)
  To: qemu-devel

On 12/13/2011 04:22 PM, Erik Lotspeich wrote:
> Thank you - I overlooked the obvious.

Actually it may be a distro bug, I suggest you report it there.

Paolo

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

* Re: [Qemu-devel] (no subject)
  2011-12-13 14:57     ` Stefan Hajnoczi
@ 2011-12-13 15:22       ` Erik Lotspeich
  2011-12-13 15:56         ` Paolo Bonzini
  0 siblings, 1 reply; 133+ messages in thread
From: Erik Lotspeich @ 2011-12-13 15:22 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel

Thank you - I overlooked the obvious.

Regards,

Erik

On Tue, Dec 13, 2011 at 8:57 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Tue, Dec 13, 2011 at 12:55 PM, Erik Lotspeich
> <erik.lotspeich@gmail.com> wrote:
>> On Tue, Dec 13, 2011 at 2:06 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>>> Please post your QEMU command-line (you can find it with "ps aux | grep
>>> qemu").
>>>
>>> If you are running through libvirt/virsh/virt-manager there may be
>>> permission requirements since the guest can be set to run as an
>>> unprivileged user without access to audio devices.   That's just a guess
>>> but worth looking into.
>>
>> Here's my qemu command line:
>>
>> qemu      5294 19.6 25.7 2444808 2101252 ?     Sl   06:47   1:00
>  ^^
> Libvirt is running the qemu-kvm process as user 'qemu'.  Does that
> user have the necessary groups (e.g. 'audio')?
>
> On my system the unprivileged user is called 'libvirt-qemu' and here's
> what I get:
>
> $ id libvirt-qemuuid=105(libvirt-qemu) gid=112(kvm) groups=112(kvm)
>
> You may need to add 'qemu' to group 'audio' or whatever is necessary
> to let it access ALSA devices or talk to a sound daemon.
> Stefan

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

* Re: [Qemu-devel] (no subject)
  2011-12-13 12:55   ` Erik Lotspeich
@ 2011-12-13 14:57     ` Stefan Hajnoczi
  2011-12-13 15:22       ` Erik Lotspeich
  0 siblings, 1 reply; 133+ messages in thread
From: Stefan Hajnoczi @ 2011-12-13 14:57 UTC (permalink / raw)
  To: Erik Lotspeich; +Cc: qemu-devel

On Tue, Dec 13, 2011 at 12:55 PM, Erik Lotspeich
<erik.lotspeich@gmail.com> wrote:
> On Tue, Dec 13, 2011 at 2:06 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> Please post your QEMU command-line (you can find it with "ps aux | grep
>> qemu").
>>
>> If you are running through libvirt/virsh/virt-manager there may be
>> permission requirements since the guest can be set to run as an
>> unprivileged user without access to audio devices.   That's just a guess
>> but worth looking into.
>
> Here's my qemu command line:
>
> qemu      5294 19.6 25.7 2444808 2101252 ?     Sl   06:47   1:00
  ^^
Libvirt is running the qemu-kvm process as user 'qemu'.  Does that
user have the necessary groups (e.g. 'audio')?

On my system the unprivileged user is called 'libvirt-qemu' and here's
what I get:

$ id libvirt-qemuuid=105(libvirt-qemu) gid=112(kvm) groups=112(kvm)

You may need to add 'qemu' to group 'audio' or whatever is necessary
to let it access ALSA devices or talk to a sound daemon.
Stefan

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

* Re: [Qemu-devel] (no subject)
  2011-12-13  8:06 ` Stefan Hajnoczi
@ 2011-12-13 12:55   ` Erik Lotspeich
  2011-12-13 14:57     ` Stefan Hajnoczi
  0 siblings, 1 reply; 133+ messages in thread
From: Erik Lotspeich @ 2011-12-13 12:55 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel

On Tue, Dec 13, 2011 at 2:06 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> Please post your QEMU command-line (you can find it with "ps aux | grep
> qemu").
>
> If you are running through libvirt/virsh/virt-manager there may be
> permission requirements since the guest can be set to run as an
> unprivileged user without access to audio devices.   That's just a guess
> but worth looking into.

Here's my qemu command line:

qemu      5294 19.6 25.7 2444808 2101252 ?     Sl   06:47   1:00
/usr/bin/qemu-kvm -S -M pc-0.14 -enable-kvm -m 2048 -smp
2,sockets=2,cores=1,threads=1 -name windowsvistax64-2 -uuid
9e05602e-6c56-ccdb-a8d6-551cf434a3f8 -nodefconfig -nodefaults -chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/windowsvistax64-2.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime
-no-hpet -no-shutdown -drive
file=/var/lib/libvirt/images/win7.raw,if=none,id=drive-ide0-0-0,format=raw
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2
-netdev tap,fd=22,id=hostnet0 -device
rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:98:e5:52,bus=pci.0,multifunction=on,addr=0x3.0x0
-netdev tap,fd=23,id=hostnet1 -device
rtl8139,netdev=hostnet1,id=net1,mac=52:54:00:71:a0:18,bus=pci.0,multifunction=on,addr=0x5.0x0
-usb -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device
intel-hda,id=sound0,bus=pci.0,multifunction=on,addr=0x6.0x0 -device
hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,multifunction=on,addr=0x4.0x0

I am running with virt-manager as root -- OpenSUSE 12.1 prompts me for
the root password if I start virt-manager as a regular user.
Normally, though, I just run it su'ed to root from a terminal window.

Thanks,

Erik

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

* Re: [Qemu-devel] (no subject)
  2011-12-13  2:50 Erik Lotspeich
@ 2011-12-13  8:06 ` Stefan Hajnoczi
  2011-12-13 12:55   ` Erik Lotspeich
  0 siblings, 1 reply; 133+ messages in thread
From: Stefan Hajnoczi @ 2011-12-13  8:06 UTC (permalink / raw)
  To: Erik Lotspeich; +Cc: qemu-devel

On Mon, Dec 12, 2011 at 08:50:39PM -0600, Erik Lotspeich wrote:
> Hi,
> 
> I posted this on qemu-discuss and didn't receive any replies; sorry
> for posting it twice.
> 
> I have OpenSUSE 12.1 and I have a 64-bit Windows 7 VM that recognizes
> the emulated ICH6 sound (HDA audio device).  Although Windows
> recognizes this sound device just fine, there is no sound from the
> Windows 7 VM.  Sound works fine in KDE and from all other applications
> on the Linux side.  I would appreciate any ideas or help?

Please post your QEMU command-line (you can find it with "ps aux | grep
qemu").

If you are running through libvirt/virsh/virt-manager there may be
permission requirements since the guest can be set to run as an
unprivileged user without access to audio devices.   That's just a guess
but worth looking into.

Stefan

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

* [Qemu-devel] (no subject)
@ 2011-12-13  2:50 Erik Lotspeich
  2011-12-13  8:06 ` Stefan Hajnoczi
  0 siblings, 1 reply; 133+ messages in thread
From: Erik Lotspeich @ 2011-12-13  2:50 UTC (permalink / raw)
  To: qemu-devel

Hi,

I posted this on qemu-discuss and didn't receive any replies; sorry
for posting it twice.

I have OpenSUSE 12.1 and I have a 64-bit Windows 7 VM that recognizes
the emulated ICH6 sound (HDA audio device).  Although Windows
recognizes this sound device just fine, there is no sound from the
Windows 7 VM.  Sound works fine in KDE and from all other applications
on the Linux side.  I would appreciate any ideas or help?

Thanks!

Regards,

Erik

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

* [Qemu-devel] (no subject)
@ 2011-12-08 12:06 wong
  0 siblings, 0 replies; 133+ messages in thread
From: wong @ 2011-12-08 12:06 UTC (permalink / raw)
  To: 9cipdtcc5, akuster, cczzaf, cupy_001, dizhidizhi, leiwang,
	sunix.kernel, qemu-devel, support

...I suppose you won�t find the place more interesting than this site!
 http://www.spassvoegel-woellstein.de/page.december.php?uvpage=16t5

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

* [Qemu-devel] (no subject)
@ 2011-11-11 21:46 Ronnie Sahlberg
  0 siblings, 0 replies; 133+ messages in thread
From: Ronnie Sahlberg @ 2011-11-11 21:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

List,

Please find a patch that adds a new section for iSCSI to qemu-doc.

This section provides much more verbose description of iSCSI and its use than
the manpage and also includes a short description on how to set up a
simple iSCSI target on loopback and then accessing it from QEMU.

The example on how to set up iSCSI Target uses the STGT iscsi target,
so the example would only work on a subset of linux/bsd systems.
I recognize also that this might be controversion, since why show how to 
configure "xyz unrelated package" in QEMU documentation.
My intention here is to provide a howto that describes how to quickly get iSCSI target up and running and to get QEMU to use it. As a quick howto for people that are not familiar with iSCSI but still want to test it out quickly.

Learning how to set up iSCSI target can often be somewhat complex and daunting
and could otherwise act as huge treshold for people that would just want to
get iSCSI running and experiment with QMEU, but would otherwise not want to
spend a lot of time learning about the target side of iscsi.


I think having examples like this is useful but see that it could be seen as
controversial.
Feel free to remove that part of the patch if you think this does not belong in the qemu docs.


regards
ronnie sahlberg

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

* [Qemu-devel] (no subject)
@ 2011-10-24 21:03 Benoît Canet
  0 siblings, 0 replies; 133+ messages in thread
From: Benoît Canet @ 2011-10-24 21:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

These patches apply against akivity memory/master.
They convert syborg to memory API and various
arm related component to VMState.

Omap boards where not modified because Linaro is
currently refactoring them.

Xscale was left apart too.

This version fix coding style issues.

>From Benoît Canet <benoit.canet@gmail.com> # This line is ignored.
From: Benoît Canet <benoit.canet@gmail.com>
Subject: 
In-Reply-To: 

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

* [Qemu-devel] (no subject)
@ 2011-10-24 10:25 王永博
  0 siblings, 0 replies; 133+ messages in thread
From: 王永博 @ 2011-10-24 10:25 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3 bytes --]

ff

[-- Attachment #2: Type: text/html, Size: 5 bytes --]

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

* [Qemu-devel] (no subject)
@ 2011-09-29 16:55 Ottavio
  0 siblings, 0 replies; 133+ messages in thread
From: Ottavio @ 2011-09-29 16:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-users

I wonder if it is possible to compile a newer version of qemu with
(the defunct) kqemu on Windows (XP)?

The winkvm project doesn't seem to be usable yet.

-- 
Ottavio

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

* [Qemu-devel] (no subject)
@ 2011-09-14 14:38 王永博
  0 siblings, 0 replies; 133+ messages in thread
From: 王永博 @ 2011-09-14 14:38 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3 bytes --]

ds

[-- Attachment #2: Type: text/html, Size: 5 bytes --]

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

* [Qemu-devel] (no subject)
@ 2011-08-03 14:50 Michael Tokarev
  0 siblings, 0 replies; 133+ messages in thread
From: Michael Tokarev @ 2011-08-03 14:50 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Jan Kiszka, Michael Tokarev, qemu-devel



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

* [Qemu-devel] (no subject)
@ 2011-06-12  2:47 Ronnie Sahlberg
  0 siblings, 0 replies; 133+ messages in thread
From: Ronnie Sahlberg @ 2011-06-12  2:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha, hch

Please find attached a patch to add built-in support for iSCSI into QEMU.
Please review and/or apply this patch.

This is the latest version of this patch and I think I have addressed all previous concerns and suggestions.


Using built-in iSCSI support has many advantages for certain use cases :

* if you have very many iSCSI devices it may be impractical to expose
all LUNs to the underlying host.

* the devices become private to the guest and are not visible to the host.
This automatically avoids polluting the page-cache on the host.

* security, the devices are private to the guest, which prevents other guests or the host itself from accessing the devices.

* security, it allows non-root users a secure way to get private and password protected access to the device by using CHAP authentication.

* migration, many other virtualization systems provide built-in iscsi clients like this. Also providing this as feature in QEMU may make it easier for such users to migrate over to QEMU/KVM.

* easier to maintain. For users with very many QEMU instances I think having guest-private iscsi targets and LUNs may be easier to manage than 'huge set of files in /dev/scsi/*'

* easier to maintain, when copying a QEMU instance from one host to another, this offers a more self-contained solution where the QEMU command line itself cotnains all required storage configuration, instead of also having to coordinate this move with setting up and tearing down open-iscsi logins on the underlying hosts.




The patch has been tested by installing and running several distributions such as RHEL6 and Ubuntu on devices, both system disk as well as the installer CDROM as being iscsi devices.

This testing has also been performed by running full QEMU under valgrind.

Performance is comparable to using open-iscsi devices.

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

* [Qemu-devel] (no subject)
@ 2011-05-31  4:56 coolman coolx
  0 siblings, 0 replies; 133+ messages in thread
From: coolman coolx @ 2011-05-31  4:56 UTC (permalink / raw)
  To: pers-zuksf-1655815864, pers-zwg24-1680121866, poleche,
	postmaster, qemu-devel, jnmintlrahul, thedaedlus, richlouise,
	meggle

http://newportnewswaterworks.co.cc/n0ow1

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

* [Qemu-devel] (no subject)
@ 2011-03-08  9:59 Stefan Hajnoczi
  0 siblings, 0 replies; 133+ messages in thread
From: Stefan Hajnoczi @ 2011-03-08  9:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori

[PULL] trace: Thread-safe simpletrace and additional trace events

The following 3 tracing commits were sent to qemu-devel.  I have made them
available for convenient pulling into qemu.git/master.

The following changes since commit 07bf23a77131668ef8db37e08d508b117655ce86:

  MAINTAINERS: add LatticeMico32 maintainer (2011-03-07 13:42:58 +0100)

are available in the git repository at:
  git://repo.or.cz/qemu/stefanha.git tracing

Stefan Hajnoczi (3):
      simpletrace: Thread-safe tracing
      trace: Trace bdrv_aio_flush()
      trace: Trace posix-aio-compat.c completion and cancellation

 block.c                |    2 +
 docs/tracing.txt       |    5 -
 posix-aio-compat.c     |    5 +
 scripts/simpletrace.py |    3 +-
 simpletrace.c          |  309 ++++++++++++++++++++++++++++++++----------------
 simpletrace.h          |    8 ++
 trace-events           |    3 +
 vl.c                   |   16 +--
 8 files changed, 229 insertions(+), 122 deletions(-)

Thanks,
Stefan

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

* [Qemu-devel] (no subject)
@ 2011-02-17 10:45 maheen butt
  0 siblings, 0 replies; 133+ messages in thread
From: maheen butt @ 2011-02-17 10:45 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

hi
I'm running MIPS user mode emulation with qemu. Whenever a memory reference instruction comes from MIPS ELF how this address is translated to host virtual address? or is there any mapping function which is used? my host machine is x86

Regards



      

[-- Attachment #2: Type: text/html, Size: 390 bytes --]

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

* Re: [Qemu-devel] (no subject)
  2011-01-04 16:06 ` Peter Maydell
@ 2011-01-04 16:12   ` Aurelien Jarno
  0 siblings, 0 replies; 133+ messages in thread
From: Aurelien Jarno @ 2011-01-04 16:12 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Tue, Jan 04, 2011 at 04:06:13PM +0000, Peter Maydell wrote:
> On 4 January 2011 15:15, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > This patch series start by a cleanup to remove dead HPPA code and fix a
> > few inconsistencies. The following patch implement implement correct
> > NaN propagation rules for MIPS and PowerPC, following commit 3
> > 54f211b1a49a7387929e22d6e63849fcba48f8a.
> 
> I haven't given a Reviewed-by: for the MIPS and PPC patches in
> this series (4,7,8) since I don't know either arch well enough to say
> whether the behaviour is right, but they look OK.
> 

Ok, thanks for the review.

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

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

* Re: [Qemu-devel] (no subject)
  2011-01-04 15:15 Aurelien Jarno
@ 2011-01-04 16:06 ` Peter Maydell
  2011-01-04 16:12   ` Aurelien Jarno
  0 siblings, 1 reply; 133+ messages in thread
From: Peter Maydell @ 2011-01-04 16:06 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: qemu-devel

On 4 January 2011 15:15, Aurelien Jarno <aurelien@aurel32.net> wrote:
> This patch series start by a cleanup to remove dead HPPA code and fix a
> few inconsistencies. The following patch implement implement correct
> NaN propagation rules for MIPS and PowerPC, following commit 3
> 54f211b1a49a7387929e22d6e63849fcba48f8a.

I haven't given a Reviewed-by: for the MIPS and PPC patches in
this series (4,7,8) since I don't know either arch well enough to say
whether the behaviour is right, but they look OK.

-- PMM

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

* [Qemu-devel] (no subject)
@ 2011-01-04 15:15 Aurelien Jarno
  2011-01-04 16:06 ` Peter Maydell
  0 siblings, 1 reply; 133+ messages in thread
From: Aurelien Jarno @ 2011-01-04 15:15 UTC (permalink / raw)
  To: qemu-devel

This patch series start by a cleanup to remove dead HPPA code and fix a
few inconsistencies. The following patch implement implement correct
NaN propagation rules for MIPS and PowerPC, following commit 3
54f211b1a49a7387929e22d6e63849fcba48f8a.

Changes from v1:
- Add "softfloat: use bits32 instead of uint32" (missing in previous
  series)
- Add "softfloat: rename *IsNaN variables to *IsQuietNaN" as suggested
  by Peter Maydell.
- Update "softfloat: fix float{32,64}_maybe_silence_nan() for MIPS" and
  "softfloat: add float{x80,128}_maybe_silence_nan()" to issue a compile
  error on SNAN_BIT_IS_ONE targets other than MIPS.
- Update "softfloat: use float{32,64,x80,128}_maybe_silence_nan()" to 
  correctly compute aIsLargerSignificand.

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

* [Qemu-devel] (no subject)
@ 2010-12-13  8:05 Ronnie Sahlberg
  0 siblings, 0 replies; 133+ messages in thread
From: Ronnie Sahlberg @ 2010-12-13  8:05 UTC (permalink / raw)
  To: qemu-devel


Please find a new block driver that IF libiscsi is present on the system
will link with this userspace client library and make qemu able to
access iscsi devices directly without exposing them to the host.

The library used is multiplatform and available from
git://github.com/sahlberg/libiscsi.git

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

* [Qemu-devel] (no subject)
@ 2010-12-06  0:39 Joao Francisco Medeiros Neto
  0 siblings, 0 replies; 133+ messages in thread
From: Joao Francisco Medeiros Neto @ 2010-12-06  0:39 UTC (permalink / raw)
  To: qemu-devel, marcelo, luiz, victor, atendimento, posto.obras,
	online, marcio.obras, computeranazias

[-- Attachment #1: Type: text/plain, Size: 46 bytes --]

http://serwis.avx.pl/index0005.php


      

[-- Attachment #2: Type: text/html, Size: 181 bytes --]

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

* [Qemu-devel] (no subject)
@ 2010-12-05 19:29 Joao Francisco Medeiros Neto
  0 siblings, 0 replies; 133+ messages in thread
From: Joao Francisco Medeiros Neto @ 2010-12-05 19:29 UTC (permalink / raw)
  To: qemu-devel, marcioc, nessa.star, debian-sc, cecilia.prefeita,
	atendimento, fausto.obras, hotmailalexandre, contabfiscal

[-- Attachment #1: Type: text/plain, Size: 63 bytes --]

http://www.folhadeitapetininga.com.br/index0005.php


      

[-- Attachment #2: Type: text/html, Size: 198 bytes --]

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

* [Qemu-devel] (no subject)
@ 2010-12-02 18:21 Joao Francisco Medeiros Neto
  0 siblings, 0 replies; 133+ messages in thread
From: Joao Francisco Medeiros Neto @ 2010-12-02 18:21 UTC (permalink / raw)
  To: debian-sc, eraldo, rosso, contabfiscal, qemu-devel, guluxlist,
	alexandre, vendas, fmartins

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]

http://cuzzucoli.it/index000.php


      

[-- Attachment #2: Type: text/html, Size: 179 bytes --]

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

* [Qemu-devel] (no subject)
@ 2010-11-28 14:28 Joao Francisco Medeiros Neto
  0 siblings, 0 replies; 133+ messages in thread
From: Joao Francisco Medeiros Neto @ 2010-11-28 14:28 UTC (permalink / raw)
  To: marcos.gabinete, reservas, jtramontina, arcelino.sacani,
	qemu-devel, mateus, fausto.obras, victor, marcioc

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

http://aigipe.it/index99.php


      

[-- Attachment #2: Type: text/html, Size: 175 bytes --]

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

* [Qemu-devel] (no subject)
@ 2010-11-27 16:37 Joao Francisco Medeiros Neto
  0 siblings, 0 replies; 133+ messages in thread
From: Joao Francisco Medeiros Neto @ 2010-11-27 16:37 UTC (permalink / raw)
  To: rosso, mateus, anderson.jsul, atendimento, qemu-devel,
	di-kazinha, falecom, reservas, deptopessoal

[-- Attachment #1: Type: text/plain, Size: 51 bytes --]

http://www.tk-motorsport.at/thunder.php


      

[-- Attachment #2: Type: text/html, Size: 186 bytes --]

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

* [Qemu-devel] (no subject)
@ 2010-11-12  9:43 Stefan Hajnoczi
  0 siblings, 0 replies; 133+ messages in thread
From: Stefan Hajnoczi @ 2010-11-12  9:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Nigel Horne



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

* [Qemu-devel] (no subject)
@ 2010-11-11  1:30 Michael Roth
  0 siblings, 0 replies; 133+ messages in thread
From: Michael Roth @ 2010-11-11  1:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: agl, abeekhof, mdroth, aliguori, ryanh, amit.shah

>From Michael Roth <mdroth@linux.vnet.ibm.com> # This line is ignored.
From: Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [RFC][PATCH v3 00/11] virtagent: host/guest RPC communication agent
In-Reply-To: 

This set of patches is meant to be applied on top of the recently submitted Virtproxy v2 patchset. It can also be obtained at:

git://repo.or.cz/qemu/mdroth.git virtproxy_v2

OVERVIEW:

There are a wide range of use cases motivating the need for a guest agent of some sort to extend the functionality/usability/control offered by QEMU. Some examples include graceful guest shutdown/reboot and notifications thereof, copy/paste syncing between host/guest, guest statistics gathering, file access, etc.

Ideally these would all be served by a single, easilly extensible agent that can be deployed in a wide range of guests. Virtagent is an XMLRPC server integrated into the Virtproxy guest daemon and aimed at providing this type of functionality.

CHANGES IN V3:

 - Integrated virtagent invocation into virtproxy chardev. Usage examples below.
 - Consolidated RPC server/client setup into a pair of init routines
 - Fixed buffer overflow in agent_viewfile() and various memory leaks

CHANGES IN V2:

 - All RPC communication is now done using asynchronous/non-blocking read/write handlers
 - Previously fork()'d RPC server loop is now integrated into qemu-vp/virtproxy i/o loop
 - Cleanups/suggestions from previous RFC

DESIGN:

There are actually 2 RPC servers:

1) a server in the guest integrated into qemu-vp, the Virtproxy guest daemon, which handles RPC requests from QEMU
2) a server in the host, integrated into the virtproxy chardev, to handle RPC requests sent by the guest agent (mainly for handling asynchronous events reported by the agent).

At the Virtagent level, communication is done via standard RPCs (HTTP between host and guest). Virtproxy transparently handles transport over a network or isa/virtio serial channel, allowing the agent to be deployed on older guests which may not support virtio-serial.

Currently there are only 2 RPCs implemented for the guest server (getfile and getdmesg), and 0 for the host. Additional RPCs can be added fairly easily, but are dependent on feedback from here and elsewhere. ping/status, shutdown, and reboot are likely candidates (although the latter 2 will likely require asynchronous notifications to the host RPC server to implement reliably).

EXAMPLE USAGE:

The commandline options are a little convoluted right now; this will addressed in later revisions.

 - Configure guest agent to talk to host via virtio-serial
    # start guest with virtio-serial/virtproxy/virtagent. for example (RHEL6rc1):
    qemu \
    -chardev virtproxy,id=test0,virtagent=on \
    -device virtio-serial \
    -device virtserialport,chardev=test0,name=virtagent0 \
    -monitor stdio
    ...
    # in the guest:
    ./qemu-vp -c virtserial-open:/dev/virtio-ports/virtagent0:- -g
    ...
    # monitor commands
    (qemu) agent_viewdmesg
    [139311.710326] wlan0: deauthenticating from 00:30:bd:f7:12:d5 by local choice (reason=3)
    [139323.469857] wlan0: deauthenticating from 00:21:29:cd:41:ee by local choice (reason=3)
    ...
    [257683.375646] wlan0: authenticated
    [257683.375684] wlan0: associate with AP 00:30:bd:f7:12:d5 (try 1)
    [257683.377932] wlan0: RX AssocResp from 00:30:bd:f7:12:d5 (capab=0x411 status=0 aid=4)
    [257683.377940] wlan0: associated
    
    (qemu) agent_viewfile /proc/meminfo
    MemTotal:        3985488 kB
    MemFree:          400524 kB
    Buffers:          220556 kB
    Cached:          2073160 kB
    SwapCached:            0 kB
    ...
    Hugepagesize:       2048 kB
    DirectMap4k:        8896 kB
    DirectMap2M:     4110336 kB

KNOWN ISSUES/PLANS:
 - the client socket that qemu connects to send RPCs is a hardcoded filepath. This is unacceptable as the socket is channel/process specific and things will break when multiple guests are started.
 - capability negotiation will be needed to handle version/architecture differences.
 - proper channel negotiation is needed to avoid hung monitors and such when a guest reboots or the guest agent is stopped for whatever reason. additionally, a timeout may need to be imposed on the amount of time the http read handler can block the monitor.
 - additional host-to-guest RPCs as well as asynchronous notifications via guest-to-host RPCs for events such as shutdown/reboot/agent up/agent down

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

* [Qemu-devel] (no subject)
@ 2010-10-31 11:17 Zamzit
  0 siblings, 0 replies; 133+ messages in thread
From: Zamzit @ 2010-10-31 11:17 UTC (permalink / raw)
  To: qemu-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1252http-equivContent-Type", Size: 1371 bytes --]

   ZAMZIT.com - buy it, sell it, Zamzit!
  

Dear friend,

We would like to invite you to join the all new auction site taking the web by storm. If you have tried ebay and you are fed up of paying the extortionate end of auction fees, like millions of other members, than check out http://www.zamzit.com/ - we only charge a small listing fee and no end of auction fees, you keep all of your profit.

If you register for free today you can take advantage of our promotional offer, you will receive a £15/$25 credit on your account which you can use to start selling your items. Act today as this will only be available for a limited time, click on the link below.

https://www.zamzit.com/login.php

We hope to see you at Zamzit.com soon.




 


Kindest Regards,


The Zamzit Team

 
www.zamzit.com  


To help stop Zamzit emails being seen as spam, please add us to your address book!


Copyright © 2010 Zamzit Ltd. All rights reserved.
Designated trademarks and brand are property of their respective owners.
The Zamzit logo is a trademarks of Zamzit Ltd.
To view our Terms and Conditions and Privacy Policy please visit our website.
Place of Reg: England & Wales. Reg No: 6038207. VAT Reg No: GB 902 2175 65

var googlead = "<\/script>\n\ \n\ <\/script>\n\ "; if (location.href.indexOf('http:') == 0) { document.write(googlead); }  

[-- Attachment #2: Type: text/html, Size: 5370 bytes --]

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

* [Qemu-devel] (no subject)
@ 2010-10-22 14:56 Stefan Hajnoczi
  0 siblings, 0 replies; 133+ messages in thread
From: Stefan Hajnoczi @ 2010-10-22 14:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Anthony Liguori, Christoph Hellwig, Stefan Hajnoczi,
	Avi Kivity

QEMU Enhanced Disk format is a disk image format that forgoes features
found in qcow2 in favor of better levels of performance and data
integrity.  Due to its simpler on-disk layout, it is possible to safely
perform metadata updates more efficiently.

Installations, suspend-to-disk, and other allocation-heavy I/O workloads
will see increased performance due to fewer I/Os and syncs.  Workloads
that do not cause new clusters to be allocated will perform similar to
raw images due to in-memory metadata caching.

The format supports sparse disk images.  It does not rely on the host
filesystem holes feature, making it a good choice for sparse disk images
that need to be transferred over channels where holes are not supported.

Backing files are supported so only deltas against a base image can be
stored.  The base image may be smaller than the image file.

The file format is extensible so that additional features can be added
later with graceful compatibility handling.  A specification for the file
format is included in this patchset.

Internal snapshots are not supported.  This eliminates the need for
additional metadata to track copy-on-write clusters.

Compression and encryption are not supported.  They add complexity and can be
implemented at other layers in the stack (i.e. inside the guest or on the
host).  Encryption has been identified as a potential future extension and the
file format allows for this.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
This code is also available from git:

http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/qed-v3

I have preserved distinct commits against v2 for easier reviewing here:

http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/qed-v3-presquash

v3:
 * Flush before L2 update when a backing file is used
 * Use QED_F_BACKING_FORMAT_NO_PROBE instead of backing_fmt header field
 * Allow non-cluster sized images
 * Implement autoclear feature bits
 * Implement backing image smaller size - reads from backing image should zero beyond EOF
 * Preserve errno in qed_find_cluster_cb() - don't dumb down to QED_CLUSTER_ERROR
 * Use ffs() instead of get_bits_from_size()
 * Remove l2_cache argument to qed_unref_l2_cache_entry
 * Eliminate L2TableAllocFunc function pointer
 * Split qed_aio_write in-place and allocating code path to make code clearer
 * Document how L2 cache is used
 * Document qed_find_cluster()
 * Update QED specification
 * Fix COPYING.LIB LGPL license file references
 * Add copyright header to qed-check.c
 * Avoid the bytes_to_str()/cvtstr()/sztostr() dependency until Jes' strtosz() goes in

v2:
 * Add QED format specification to documentation
 * Use __builtin_ctzl() for get_bits_from_size()
 * Fine-grained table locking to allow concurrent allocating write requests
 * Fix qemu_free() instead of qemu_vfree() in qed_unref_l2_cache_entry()
 * Comment clean-ups

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

* [Qemu-devel] (no subject)
@ 2010-05-18  7:31 Corentin Chary
  0 siblings, 0 replies; 133+ messages in thread
From: Corentin Chary @ 2010-05-18  7:31 UTC (permalink / raw)
  To: qemu-devel

>From 42415cc70a087e9a280667eddbeb2af1029c96a0 Mon Sep 17 00:00:00 2001
From: Corentin Chary <corentincj@iksaif.net>
Date: Tue, 18 May 2010 09:23:48 +0200
Subject: [PATCH 00/10] vnc encodings
Cc: Anthony Liguori <aliguori@linux.vnet.ibm.com>,
    Alexander Graf <agraf@suse.de>,
    Adam Litke <agl@us.ibm.com>

Hi,
I this series you'll find zlib fixes and a new tight encoding.
Tight implementation is inspired (stolen ?) from libvncserver/tightvnc/tigervnc,
but rewritten to match QEMU VNC implementation and coding style.
Tight encoding still lacks gradient and jpeg, but some results [1] [2] show
that it performs better than zlib and hextile.

Thanks,

[1] http://xf.iksaif.net/blog/index.php?post/2010/05/11/GsoC-2010-QEMU%3A-First-%28dumb%29-tight-benchmarks
[2] http://xf.iksaif.net/blog/index.php?post/2010/05/18/QEMU%3A-some-charts-on-tight-zlib-and-hextile

Corentin Chary (10):
  vnc: refactor set_encodings
  vnc: really call zlib if we want zlib
  vnc: only use a single zlib stream
  vnc: adjust compression zstream level
  vnc: add basic tight support
  vnc: add support for tight fill encoding
  vnc: don't clear zlib stream on set_encoding
  vnc: remove memory leaks in zlib and tight encoding
  vnc: tight: add palette encoding
  vnc: update copyrights for vnc-encoding-tight.c

 Makefile               |    2 +
 Makefile.objs          |    1 +
 vnc-encoding-hextile.c |    5 +-
 vnc-encoding-tight.c   |  945 ++++++++++++++++++++++++++++++++++++++++++++++++
 vnc-encoding-tight.h   |  200 ++++++++++
 vnc-encoding-zlib.c    |   43 ++-
 vnc.c                  |   79 +++--
 vnc.h                  |   24 +-
 8 files changed, 1246 insertions(+), 53 deletions(-)
 create mode 100644 vnc-encoding-tight.c
 create mode 100644 vnc-encoding-tight.h

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

* [Qemu-devel] (no subject)
@ 2010-02-10 18:15 Stephen Isard
  0 siblings, 0 replies; 133+ messages in thread
From: Stephen Isard @ 2010-02-10 18:15 UTC (permalink / raw)
  To: qemu-devel

Hello,

I hope you will excuse a naive question here.  I'm not getting any 
response on the users' lists.

I'm wondering whether shutting down a guest machine with the quit 
command in the monitor can corrupt the snapshots saved with savevm.  As 
I understand it,  quit will have an effect on the virtual guest similar 
to pulling the plug on a physical machine, so could leave it in a funny 
state.  Since the snapshots appear to be stored on the guest's hard 
disk, it seems conceivable (in my state of ignorance) that they could be 
put at risk.  Is that in fact possible?

Thanks for your attention.

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

* [Qemu-devel] (no subject)
@ 2009-10-31  1:07 Jason McMullan
  0 siblings, 0 replies; 133+ messages in thread
From: Jason McMullan @ 2009-10-31  1:07 UTC (permalink / raw)
  To: qemu-devel

>From cc0481503722124f085d785637aeea9ea51fab9b Mon Sep 17 00:00:00 2001
From: Jason S. McMullan <jason.mcmullan@gmail.com>
Date: Wed, 28 Oct 2009 00:56:00 -0400
Subject: [PATCH] hw/sd: Support SDHC size cards

Signed-off-by: Jason S. McMullan <jason.mcmullan@gmail.com>
---
 hw/sd.c |  153 ++++++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 93 insertions(+), 60 deletions(-)

diff --git a/hw/sd.c b/hw/sd.c
index 9888547..4d306af 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -81,7 +81,7 @@ struct SDState {
     uint32_t vhs;
     int wp_switch;
     int *wp_groups;
-    uint32_t size;
+    uint64_t size;
     int blk_len;
     uint32_t erase_start;
     uint32_t erase_end;
@@ -92,7 +92,7 @@ struct SDState {
     int spi;
     int current_cmd;
     int blk_written;
-    uint32_t data_start;
+    uint64_t data_start;
     uint32_t data_offset;
     uint8_t data[512];
     qemu_irq readonly_cb;
@@ -249,37 +249,59 @@ static const uint8_t sd_csd_rw_mask[16] = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe,
 };
 
-static void sd_set_csd(SDState *sd, uint32_t size)
+static void sd_set_csd(SDState *sd, uint64_t size)
 {
     uint32_t csize = (size >> (CMULT_SHIFT + HWBLOCK_SHIFT)) - 1;
     uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1;
     uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1;
 
-    sd->csd[0] = 0x00;		/* CSD structure */
-    sd->csd[1] = 0x26;		/* Data read access-time-1 */
-    sd->csd[2] = 0x00;		/* Data read access-time-2 */
-    sd->csd[3] = 0x5a;		/* Max. data transfer rate */
-    sd->csd[4] = 0x5f;		/* Card Command Classes */
-    sd->csd[5] = 0x50 |		/* Max. read data block length */
-        HWBLOCK_SHIFT;
-    sd->csd[6] = 0xe0 |		/* Partial block for read allowed */
-        ((csize >> 10) & 0x03);
-    sd->csd[7] = 0x00 |		/* Device size */
-        ((csize >> 2) & 0xff);
-    sd->csd[8] = 0x3f |		/* Max. read current */
-        ((csize << 6) & 0xc0);
-    sd->csd[9] = 0xfc |		/* Max. write current */
-        ((CMULT_SHIFT - 2) >> 1);
-    sd->csd[10] = 0x40 |	/* Erase sector size */
-        (((CMULT_SHIFT - 2) << 7) & 0x80) | (sectsize >> 1);
-    sd->csd[11] = 0x00 |	/* Write protect group size */
-        ((sectsize << 7) & 0x80) | wpsize;
-    sd->csd[12] = 0x90 |	/* Write speed factor */
-        (HWBLOCK_SHIFT >> 2);
-    sd->csd[13] = 0x20 |	/* Max. write data block length */
-        ((HWBLOCK_SHIFT << 6) & 0xc0);
-    sd->csd[14] = 0x00;		/* File format group */
-    sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1;
+    if (size <= 0x40000000) {
+	    sd->csd[0] = 0x00;		/* CSD structure */
+	    sd->csd[1] = 0x26;		/* Data read access-time-1 */
+	    sd->csd[2] = 0x00;		/* Data read access-time-2 */
+	    sd->csd[3] = 0x5a;		/* Max. data transfer rate */
+	    sd->csd[4] = 0x5f;		/* Card Command Classes */
+	    sd->csd[5] = 0x50 |		/* Max. read data block length */
+		HWBLOCK_SHIFT;
+	    sd->csd[6] = 0xe0 |		/* Partial block for read allowed */
+		((csize >> 10) & 0x03);
+	    sd->csd[7] = 0x00 |		/* Device size */
+		((csize >> 2) & 0xff);
+	    sd->csd[8] = 0x3f |		/* Max. read current */
+		((csize << 6) & 0xc0);
+	    sd->csd[9] = 0xfc |		/* Max. write current */
+		((CMULT_SHIFT - 2) >> 1);
+	    sd->csd[10] = 0x40 |	/* Erase sector size */
+		(((CMULT_SHIFT - 2) << 7) & 0x80) | (sectsize >> 1);
+	    sd->csd[11] = 0x00 |	/* Write protect group size */
+		((sectsize << 7) & 0x80) | wpsize;
+	    sd->csd[12] = 0x90 |	/* Write speed factor */
+		(HWBLOCK_SHIFT >> 2);
+	    sd->csd[13] = 0x20 |	/* Max. write data block length */
+		((HWBLOCK_SHIFT << 6) & 0xc0);
+	    sd->csd[14] = 0x00;		/* File format group */
+	    sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1;
+    } else {
+    	    size /= 512 * 1024;
+    	    size -= 1;
+    	    sd->csd[0] = 0x40;
+    	    sd->csd[1] = 0x0e;
+    	    sd->csd[2] = 0x00;
+    	    sd->csd[3] = 0x32;
+    	    sd->csd[4] = 0x5b;
+    	    sd->csd[5] = 0x59;
+    	    sd->csd[6] = 0x00;
+    	    sd->csd[7] = (size >> 16) & 0xff;
+    	    sd->csd[8] = (size >> 8) & 0xff;
+    	    sd->csd[9] = (size & 0xff);
+    	    sd->csd[10] = 0x7f;
+    	    sd->csd[11] = 0x80;
+    	    sd->csd[12] = 0x0a;
+    	    sd->csd[13] = 0x40;
+    	    sd->csd[14] = 0x00;
+    	    sd->csd[15] = 0x00;
+    	    sd->ocr |= (1 << 30);
+    }
 }
 
 static void sd_set_rca(SDState *sd)
@@ -362,7 +384,7 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response)
 
 static void sd_reset(SDState *sd, BlockDriverState *bdrv)
 {
-    uint32_t size;
+    uint64_t size;
     uint64_t sect;
 
     if (bdrv) {
@@ -372,10 +394,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
     }
     sect <<= 9;
 
-    if (sect > 0x40000000)
-        size = 0x40000000;	/* 1 gig */
-    else
-        size = sect + 1;
+    size = sect + 1;
 
     sect = (size >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) + 1;
 
@@ -460,7 +479,7 @@ static void sd_erase(SDState *sd)
             sd->card_status |= WP_ERASE_SKIP;
 }
 
-static uint32_t sd_wpbits(SDState *sd, uint32_t addr)
+static uint32_t sd_wpbits(SDState *sd, uint64_t addr)
 {
     uint32_t i, wpnum;
     uint32_t ret = 0;
@@ -583,7 +602,14 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
                                        SDRequest req)
 {
     uint32_t rca = 0x0000;
+    uint64_t addr;
 
+    if (sd->ocr & (1 << 30)) {
+    	    addr = (uint64_t)req.arg << 9;
+    } else {
+    	    addr = req.arg;
+    }
+    
     if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_adtc)
         rca = req.arg >> 16;
 
@@ -735,7 +761,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
                 break;
             sd->state = sd_sendingdata_state;
             memcpy(sd->data, sd->csd, 16);
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
             return sd_r1;
 
@@ -757,7 +783,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
                 break;
             sd->state = sd_sendingdata_state;
             memcpy(sd->data, sd->cid, 16);
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
             return sd_r1;
 
@@ -850,7 +876,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
         switch (sd->state) {
         case sd_transfer_state:
             sd->state = sd_sendingdata_state;
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
 
             if (sd->data_start + sd->blk_len > sd->size)
@@ -866,7 +892,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
         switch (sd->state) {
         case sd_transfer_state:
             sd->state = sd_sendingdata_state;
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
 
             if (sd->data_start + sd->blk_len > sd->size)
@@ -888,7 +914,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
             if (sd->spi)
                 break;
             sd->state = sd_receivingdata_state;
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
             sd->blk_written = 0;
 
@@ -914,7 +940,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
             if (sd->spi)
                 break;
             sd->state = sd_receivingdata_state;
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
             sd->blk_written = 0;
 
@@ -965,13 +991,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
     case 28:	/* CMD28:  SET_WRITE_PROT */
         switch (sd->state) {
         case sd_transfer_state:
-            if (req.arg >= sd->size) {
+            if (addr >= sd->size) {
                 sd->card_status = ADDRESS_ERROR;
                 return sd_r1b;
             }
 
             sd->state = sd_programming_state;
-            sd->wp_groups[req.arg >> (HWBLOCK_SHIFT +
+            sd->wp_groups[addr >> (HWBLOCK_SHIFT +
                             SECTOR_SHIFT + WPGROUP_SHIFT)] = 1;
             /* Bzzzzzzztt .... Operation complete.  */
             sd->state = sd_transfer_state;
@@ -985,13 +1011,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
     case 29:	/* CMD29:  CLR_WRITE_PROT */
         switch (sd->state) {
         case sd_transfer_state:
-            if (req.arg >= sd->size) {
+            if (addr >= sd->size) {
                 sd->card_status = ADDRESS_ERROR;
                 return sd_r1b;
             }
 
             sd->state = sd_programming_state;
-            sd->wp_groups[req.arg >> (HWBLOCK_SHIFT +
+            sd->wp_groups[addr >> (HWBLOCK_SHIFT +
                             SECTOR_SHIFT + WPGROUP_SHIFT)] = 0;
             /* Bzzzzzzztt .... Operation complete.  */
             sd->state = sd_transfer_state;
@@ -1007,7 +1033,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
         case sd_transfer_state:
             sd->state = sd_sendingdata_state;
             *(uint32_t *) sd->data = sd_wpbits(sd, req.arg);
-            sd->data_start = req.arg;
+            sd->data_start = addr;
             sd->data_offset = 0;
             return sd_r1b;
 
@@ -1322,11 +1348,11 @@ int sd_do_command(SDState *sd, SDRequest *req,
     return rsplen;
 }
 
-/* No real need for 64 bit addresses here */
-static void sd_blk_read(SDState *sd, uint32_t addr, uint32_t len)
+static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)
 {
-    uint32_t end = addr + len;
+    uint64_t end = addr + len;
 
+    DPRINTF("sd_blk_read: addr = 0x%08llx, len = %d\n", (unsigned long long)addr, len);
     if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) == -1) {
         fprintf(stderr, "sd_blk_read: read error on host side\n");
         return;
@@ -1344,9 +1370,9 @@ static void sd_blk_read(SDState *sd, uint32_t addr, uint32_t len)
         memcpy(sd->data, sd->buf + (addr & 511), len);
 }
 
-static void sd_blk_write(SDState *sd, uint32_t addr, uint32_t len)
+static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len)
 {
-    uint32_t end = addr + len;
+    uint64_t end = addr + len;
 
     if ((addr & 511) || len < 512)
         if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) == -1) {
@@ -1505,6 +1531,7 @@ uint8_t sd_read_data(SDState *sd)
 {
     /* TODO: Append CRCs */
     uint8_t ret;
+    int io_len;
 
     if (!sd->bdrv || !bdrv_is_inserted(sd->bdrv) || !sd->enable)
         return 0x00;
@@ -1517,6 +1544,12 @@ uint8_t sd_read_data(SDState *sd)
     if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION))
         return 0x00;
 
+    if (sd->ocr & (1 << 30)) {
+	io_len = 512;
+    } else {
+    	io_len = sd->blk_len;
+    }
+
     switch (sd->current_cmd) {
     case 6:	/* CMD6:   SWITCH_FUNCTION */
         ret = sd->data[sd->data_offset ++];
@@ -1535,13 +1568,13 @@ uint8_t sd_read_data(SDState *sd)
 
     case 11:	/* CMD11:  READ_DAT_UNTIL_STOP */
         if (sd->data_offset == 0)
-            BLK_READ_BLOCK(sd->data_start, sd->blk_len);
+            BLK_READ_BLOCK(sd->data_start, io_len);
         ret = sd->data[sd->data_offset ++];
 
-        if (sd->data_offset >= sd->blk_len) {
-            sd->data_start += sd->blk_len;
+        if (sd->data_offset >= io_len) {
+            sd->data_start += io_len;
             sd->data_offset = 0;
-            if (sd->data_start + sd->blk_len > sd->size) {
+            if (sd->data_start + io_len > sd->size) {
                 sd->card_status |= ADDRESS_ERROR;
                 break;
             }
@@ -1557,22 +1590,22 @@ uint8_t sd_read_data(SDState *sd)
 
     case 17:	/* CMD17:  READ_SINGLE_BLOCK */
         if (sd->data_offset == 0)
-            BLK_READ_BLOCK(sd->data_start, sd->blk_len);
+            BLK_READ_BLOCK(sd->data_start, io_len);
         ret = sd->data[sd->data_offset ++];
 
-        if (sd->data_offset >= sd->blk_len)
+        if (sd->data_offset >= io_len)
             sd->state = sd_transfer_state;
         break;
 
     case 18:	/* CMD18:  READ_MULTIPLE_BLOCK */
         if (sd->data_offset == 0)
-            BLK_READ_BLOCK(sd->data_start, sd->blk_len);
+            BLK_READ_BLOCK(sd->data_start, io_len);
         ret = sd->data[sd->data_offset ++];
 
-        if (sd->data_offset >= sd->blk_len) {
-            sd->data_start += sd->blk_len;
+        if (sd->data_offset >= io_len) {
+            sd->data_start += io_len;
             sd->data_offset = 0;
-            if (sd->data_start + sd->blk_len > sd->size) {
+            if (sd->data_start + io_len > sd->size) {
                 sd->card_status |= ADDRESS_ERROR;
                 break;
             }
-- 
1.6.3.3

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

* [Qemu-devel] (no subject)
@ 2009-07-01 21:26 G 3
  0 siblings, 0 replies; 133+ messages in thread
From: G 3 @ 2009-07-01 21:26 UTC (permalink / raw)
  To: qemu-devel

> Stefan Weil wrote:
>
>     strnlen is a GNU extension which is missing in mingw32
>     and perhaps other build environments.
>
>
>     So we should avoid it and replace it by standard functions.
>
>
>     Signed-off-by: Stefan Weil <address@hidden>
>     ---
>      block.c |    7 ++++++-
>      1 files changed, 6 insertions(+), 1 deletions(-)
>
>
>     diff --git a/block.c b/block.c
>     index c66c031..79b3313 100644
>     --- a/block.c
>     +++ b/block.c
>     @@ -225,9 +225,14 @@ static BlockDriver *find_protocol(const char 
> *filename)
>     {
>     BlockDriver *drv1;
>     char protocol[128];
>     - int len = strnlen(filename, 127)+1;
>     + int len;
>     const char *p;
>     + len = strlen(filename) + 1;
>     + if (len > sizeof(protocol)) {
>     + len = sizeof(protocol);
>     + }
>     +
>     #ifdef _WIN32
>     if (is_windows_drive(filename) ||
>     is_windows_drive_prefix(filename))
>
>
> Or something like this?
> #ifdef __MINGW32__
> size_t strnlen (const char *string, size_t maxlen)
> {
>   const char *end = memchr (string, '\0', maxlen);
>   return end ? (size_t) (end - string) : maxlen;
> };
> #endif

block.c doesn't compile on Mac OS 10.3. I second the notion of removing 
strnlen.

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

* [Qemu-devel] (no subject)
@ 2009-03-17 20:37 Uri Lublin
  0 siblings, 0 replies; 133+ messages in thread
From: Uri Lublin @ 2009-03-17 20:37 UTC (permalink / raw)
  To: qemu-devel

In this patchset there are three main features:
1. Introduce Qcow2 extensions.
2. Keep backing file format such that no probing is needed.
3. Keep track of highest-allocated-offset and report it upon a user request.
4. Add an open-flag to distinguish between a leaf image and a backing file
   (base image). Also keep the open-flags so we can later use them to
   close and reopen images.

1. Qcow2 extensions are build of magic (id) len (in bytes) and data.
They reside between the end of the header and the backing filename (if exists).
Unknown extensions are ignored (assumed to be added by a newer version)
Based on a work done by Shahar Frank.

2. By keeping the backing file format we:
a. Provide a way to know the backing file format without probing
   it (setting the format at creation time).
b. Enable using qcow2 format over host block devices.
   (only if the user specifically asks for it, by providing the format
   at creation time).

I've added bdrv_create2 and drv->bdrv_create2 (implemented only
by block-qcow2 currently) to pass the backing-format to create.

Also fixes a security flaw found by Daniel P. Berrange on [1]
which summarizes: "Autoprobing: just say no."

[1] http://lists.gnu.org/archive/html/qemu-devel/2008-12/msg01083.html

3. One of the main usage for highest-allocated-offset is to know and act
upon a case of end-of-storage-space. Instead of waiting for
-ENOSPACE (which now may cause the VM to stop), one can
define a threshold and extend the diskspace allocated for
the image.
This info is also good for management systems, so they
can report the user disk space status.

4. With bdrv_close and reopen capability we can possibly:
   a. Open backing files with read-only permission, and reopen with RW
      if needed.
   b. Reopen on destination side after migration before starting to run
      This solves a case where the source changes the disk (especially
      meta-data) while migration is in process.
   c. Check open-flags to keep track of highest-allocated-offset for 
      only leaf images.
      

Changes from v5:
   Patchset includes newly introduced qcow2 extensions.
   Usage of such qcow2 extensions for keeping both backing format and 
       highest-allocated-offset.
   No scanning of qcow2 images upon open.
   Not yet support for num-free.
   Added bdrv_close_all + calling it at end of main.
   Support highest_alloc only for leaf images.

Uri Lublin (14):
      Introducing qcow2 extensions
      block: support known backing format for image create and open
      block-qcow2: keep backing file format in a qcow2 extension
      qemu-img: adding a "-F base_fmt" option to "qemu-img create -b"
      block-qcow2: keep highest allocated offset
      block-qcow2: export highest-alloc through BlockDriverInfo and get_info()
      block: info blockstats: show highest_allocated if exists
      Add a bdrv_close_all() and  call it at the end of main()
      block-qcow2: keep highest alloc offset in a qcow2 extension
      qemu-img: info: show highest_alloc if exists
      qcow2: qcow_read_extensions: make "advance offset over extension" common
      block: pass BDRV_BACKING flag to open of a backing file
      block: keep flags an image was opened with
      block-qcow2: do not keep track of highest-alloc for backing files

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

* Re: [Qemu-devel] (no subject)
  2009-01-30  2:43 ` Paul Brook
@ 2009-02-01 15:20   ` Uri Lublin
  0 siblings, 0 replies; 133+ messages in thread
From: Uri Lublin @ 2009-02-01 15:20 UTC (permalink / raw)
  To: qemu-devel

Paul Brook wrote:
> On Thursday 29 January 2009, Uri Lublin wrote:
>> The following patch fixes saving/loading/migrating a VM with
>> multiple e1000 NICs.
> 
> I don't know what problems you're seeing, but this is definitely not the right 
> way to fix them.
> 
>> It turns out many devices use -1 as instance (for register_savevm),
>> which is wrong in cases where there can exist multiple such
>> devices within a single VM.
> 
> No it isn't. -1 means automatically assign IDs, and is what everything should 
> be using. The explicit ID argument is a historcal wart. Read the comment 
> above register_savevm.
> 
> Paul
> 

Paul,

You are right, I was wrong.
This patch is a fix for an older qemu, and is not needed.

Thanks for catching that,
     Uri.

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

* Re: [Qemu-devel] (no subject)
  2009-01-29 19:54 Uri Lublin
@ 2009-01-30  2:43 ` Paul Brook
  2009-02-01 15:20   ` Uri Lublin
  0 siblings, 1 reply; 133+ messages in thread
From: Paul Brook @ 2009-01-30  2:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hello, Uri Lublin

On Thursday 29 January 2009, Uri Lublin wrote:
> The following patch fixes saving/loading/migrating a VM with
> multiple e1000 NICs.

I don't know what problems you're seeing, but this is definitely not the right 
way to fix them.

> It turns out many devices use -1 as instance (for register_savevm),
> which is wrong in cases where there can exist multiple such
> devices within a single VM.

No it isn't. -1 means automatically assign IDs, and is what everything should 
be using. The explicit ID argument is a historcal wart. Read the comment 
above register_savevm.

Paul

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

* [Qemu-devel] (no subject)
@ 2009-01-29 19:54 Uri Lublin
  2009-01-30  2:43 ` Paul Brook
  0 siblings, 1 reply; 133+ messages in thread
From: Uri Lublin @ 2009-01-29 19:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hello, Uri Lublin

The following patch fixes saving/loading/migrating a VM with
multiple e1000 NICs.

It turns out many devices use -1 as instance (for register_savevm),
which is wrong in cases where there can exist multiple such
devices within a single VM.

--------------------------------------------

>From e89f237fbfbeed937ccf63a4dcd20955c41f4081 Mon Sep 17 00:00:00 2001
From: Uri Lublin <uril@redhat.com>
Date: Thu, 29 Jan 2009 21:37:53 +0200
Subject: [PATCH] e1000: fix register_savevm for multiple nics

Solution is similar to other devices (a static variable).

Signed-off-by: Uri Lublin <uril@redhat.com>
---
 hw/e1000.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index a38ab73..f62743d 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1040,8 +1040,8 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
     E1000State *d;
     uint8_t *pci_conf;
     uint16_t checksum = 0;
-    static const char info_str[] = "e1000";
     int i;
+    static int nnics=0;
 
     d = (E1000State *)pci_register_device(bus, "e1000",
                 sizeof(E1000State), devfn, NULL, NULL);
@@ -1092,5 +1092,5 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
 
     qemu_format_nic_info_str(d->vc, d->nd->macaddr);
 
-    register_savevm(info_str, -1, 2, nic_save, nic_load, d);
+    register_savevm("e1000", nnics++, 2, nic_save, nic_load, d);
 }
-- 
1.6.0.6

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

* [Qemu-devel] (no subject)
@ 2008-12-13 21:18 froydnj
  0 siblings, 0 replies; 133+ messages in thread
From: froydnj @ 2008-12-13 21:18 UTC (permalink / raw)


>From 9dfed322ae613671cb93cb3422c376c07ac4bbe4 Mon Sep 17 00:00:00 2001
From: Nathan Froyd <froydnj@codesourcery.com>
Date: Sat, 13 Dec 2008 11:21:43 -0800
Subject: [PATCH] Use float_relation_* constants.

Use float_relation_* constants rather than magic numbers in
softfloat-native comparison routines.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
 fpu/softfloat-native.c |   48 ++++++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/fpu/softfloat-native.c b/fpu/softfloat-native.c
index 0b24bab..cd88113 100644
--- a/fpu/softfloat-native.c
+++ b/fpu/softfloat-native.c
@@ -220,25 +220,25 @@ float32 float32_sqrt( float32 a STATUS_PARAM)
 int float32_compare( float32 a, float32 b STATUS_PARAM )
 {
     if (a < b) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (a > b) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float32_compare_quiet( float32 a, float32 b STATUS_PARAM )
 {
     if (isless(a, b)) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (isgreater(a, b)) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float32_is_signaling_nan( float32 a1)
@@ -391,25 +391,25 @@ float64 float64_sqrt( float64 a STATUS_PARAM)
 int float64_compare( float64 a, float64 b STATUS_PARAM )
 {
     if (a < b) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (a > b) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float64_compare_quiet( float64 a, float64 b STATUS_PARAM )
 {
     if (isless(a, b)) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (isgreater(a, b)) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float64_is_signaling_nan( float64 a1)
@@ -483,25 +483,25 @@ floatx80 floatx80_sqrt( floatx80 a STATUS_PARAM)
 int floatx80_compare( floatx80 a, floatx80 b STATUS_PARAM )
 {
     if (a < b) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (a > b) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int floatx80_compare_quiet( floatx80 a, floatx80 b STATUS_PARAM )
 {
     if (isless(a, b)) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (isgreater(a, b)) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int floatx80_is_signaling_nan( floatx80 a1)
-- 
1.6.0.5

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

* [Qemu-devel] (no subject)
@ 2008-12-13 19:31 froydnj
  0 siblings, 0 replies; 133+ messages in thread
From: froydnj @ 2008-12-13 19:31 UTC (permalink / raw)


>From 9dfed322ae613671cb93cb3422c376c07ac4bbe4 Mon Sep 17 00:00:00 2001
From: Nathan Froyd <froydnj@codesourcery.com>
Date: Sat, 13 Dec 2008 11:21:43 -0800
Subject: [PATCH] Use float_relation_* constants.

Use float_relation_* constants rather than magic numbers in
softfloat-native comparison routines.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
 fpu/softfloat-native.c |   48 ++++++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/fpu/softfloat-native.c b/fpu/softfloat-native.c
index 0b24bab..cd88113 100644
--- a/fpu/softfloat-native.c
+++ b/fpu/softfloat-native.c
@@ -220,25 +220,25 @@ float32 float32_sqrt( float32 a STATUS_PARAM)
 int float32_compare( float32 a, float32 b STATUS_PARAM )
 {
     if (a < b) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (a > b) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float32_compare_quiet( float32 a, float32 b STATUS_PARAM )
 {
     if (isless(a, b)) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (isgreater(a, b)) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float32_is_signaling_nan( float32 a1)
@@ -391,25 +391,25 @@ float64 float64_sqrt( float64 a STATUS_PARAM)
 int float64_compare( float64 a, float64 b STATUS_PARAM )
 {
     if (a < b) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (a > b) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float64_compare_quiet( float64 a, float64 b STATUS_PARAM )
 {
     if (isless(a, b)) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (isgreater(a, b)) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int float64_is_signaling_nan( float64 a1)
@@ -483,25 +483,25 @@ floatx80 floatx80_sqrt( floatx80 a STATUS_PARAM)
 int floatx80_compare( floatx80 a, floatx80 b STATUS_PARAM )
 {
     if (a < b) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (a > b) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int floatx80_compare_quiet( floatx80 a, floatx80 b STATUS_PARAM )
 {
     if (isless(a, b)) {
-        return -1;
+        return float_relation_less;
     } else if (a == b) {
-        return 0;
+        return float_relation_equal;
     } else if (isgreater(a, b)) {
-        return 1;
+        return float_relation_greater;
     } else {
-        return 2;
+        return float_relation_unordered;
     }
 }
 int floatx80_is_signaling_nan( floatx80 a1)
-- 
1.6.0.5

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

* Re: [Qemu-devel] (no subject)
  2008-12-11 22:12 Hollis Blanchard
@ 2008-12-11 22:43 ` Aurelien Jarno
  0 siblings, 0 replies; 133+ messages in thread
From: Aurelien Jarno @ 2008-12-11 22:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hollis Blanchard

On Thu, Dec 11, 2008 at 04:12:33PM -0600, Hollis Blanchard wrote:
> I'm not familiar with this device, but I'm fairly certain the writel handler is
> not supposed to recurse.
>
> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

Thanks, applied.

> diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
> index 4144dae..1d8b6ab 100644
> --- a/hw/ppc405_boards.c
> +++ b/hw/ppc405_boards.c
> @@ -129,9 +129,9 @@ static uint32_t ref405ep_fpga_readl (void *opaque, target_phys_addr_t addr)
>  static void ref405ep_fpga_writel (void *opaque,
>                                    target_phys_addr_t addr, uint32_t value)
>  {
> -    ref405ep_fpga_writel(opaque, addr, (value >> 24) & 0xFF);
> -    ref405ep_fpga_writel(opaque, addr + 1, (value >> 16) & 0xFF);
> -    ref405ep_fpga_writel(opaque, addr + 2, (value >> 8) & 0xFF);
> +    ref405ep_fpga_writeb(opaque, addr, (value >> 24) & 0xFF);
> +    ref405ep_fpga_writeb(opaque, addr + 1, (value >> 16) & 0xFF);
> +    ref405ep_fpga_writeb(opaque, addr + 2, (value >> 8) & 0xFF);
>      ref405ep_fpga_writeb(opaque, addr + 3, value & 0xFF);
>  }
>  
> 
> 
> 

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

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

* [Qemu-devel] (no subject)
@ 2008-12-11 22:12 Hollis Blanchard
  2008-12-11 22:43 ` Aurelien Jarno
  0 siblings, 1 reply; 133+ messages in thread
From: Hollis Blanchard @ 2008-12-11 22:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hollis Blanchard

I'm not familiar with this device, but I'm fairly certain the writel handler is
not supposed to recurse.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index 4144dae..1d8b6ab 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -129,9 +129,9 @@ static uint32_t ref405ep_fpga_readl (void *opaque, target_phys_addr_t addr)
 static void ref405ep_fpga_writel (void *opaque,
                                   target_phys_addr_t addr, uint32_t value)
 {
-    ref405ep_fpga_writel(opaque, addr, (value >> 24) & 0xFF);
-    ref405ep_fpga_writel(opaque, addr + 1, (value >> 16) & 0xFF);
-    ref405ep_fpga_writel(opaque, addr + 2, (value >> 8) & 0xFF);
+    ref405ep_fpga_writeb(opaque, addr, (value >> 24) & 0xFF);
+    ref405ep_fpga_writeb(opaque, addr + 1, (value >> 16) & 0xFF);
+    ref405ep_fpga_writeb(opaque, addr + 2, (value >> 8) & 0xFF);
     ref405ep_fpga_writeb(opaque, addr + 3, value & 0xFF);
 }
 

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

* [Qemu-devel] (no subject)
@ 2008-11-14 15:38 sniper
  0 siblings, 0 replies; 133+ messages in thread
From: sniper @ 2008-11-14 15:38 UTC (permalink / raw)
  To: sniper; +Cc: skyeye-developer, qhfeng.kernel, qemu-devel

f

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

* [Qemu-devel] (no subject)
@ 2008-08-21 14:27 Paweł Tulik
  0 siblings, 0 replies; 133+ messages in thread
From: Paweł Tulik @ 2008-08-21 14:27 UTC (permalink / raw)
  To: qemu-devel

Is it possible to use breakpoints on memory access in kernel mode 
debugger running on QEMU with x86 platform?

----------------------------------------------------
Kino na Molo w Sopocie!
Olbrzymi ekran projekcyjny! Największe hity filmowe! 
Codziennie o 21.30 przez cały Sierpień. Wstęp wolny. - Szczegóły:
http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2FKinoNaMolo.html&sid=456

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

* [Qemu-devel] (no subject)
@ 2007-04-10 13:34 Stuart Anderson
  0 siblings, 0 replies; 133+ messages in thread
From: Stuart Anderson @ 2007-04-10 13:34 UTC (permalink / raw)
  To: qemu-devel


I'm trying to test my fixes to the linux-user emulation on some additonal
architectures now, but I'm running into problems. I can debug these some,
but any suggestions or guidence, especially from people more familiar
with the architecture core code, would be appreciated.

The environment is a Debian x86_64 server running Etch, with target
environments built using debootstrap.


MIPS:

Bash seems to start up ok, but when I run a command in it, it hangs
until I hit return a second time, and then bash exits w/ an uncaught
target signal.

projects:~/upstream/qemu# mips-linux-user/qemu-mips -L /mirror0/chroots/mips/ /mirror0/chroots/mips/bin/bash
projects:~/upstream/qemu# ps

   PID TTY          TIME CMD
   18786 pts/1    00:00:00 bash
   20057 pts/1    00:00:00 ps
   20058 pts/1    00:00:00 qemu-mips
qemu: uncaught target signal 25 (Continued) - exiting
projects:~/upstream/qemu#

PPC:

I am unable to get any executable to run.


projects:~/upstream/qemu# ./ppc-linux-user/qemu-ppc -L /mirror0/chroots/ppc/ /mirror0/chroots/ppc/bin/bash
init_ppc_proc: PVR 00080000 mask ffffffff => 00080000
Segmentation fault
projects:~/upstream/qemu#


 		Thanks,


                                 Stuart

Stuart R. Anderson                               anderson@netsweng.com
Network & Software Engineering                   http://www.netsweng.com/
1024D/37A79149:                                  0791 D3B8 9A4C 2CDC A31F
                                                  BD03 0A62 E534 37A7 9149

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

* Re: [Qemu-devel] (no subject)
@ 2007-03-03 23:09 Ben Taylor
  0 siblings, 0 replies; 133+ messages in thread
From: Ben Taylor @ 2007-03-03 23:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: jeremy fenelon


---- jeremy fenelon <jcfenelon@yahoo.com> wrote: 
> Hey guys thanks for a great product. I don't know if its been documented already but I was able to install windows xp  on qemu with a HP Laptop Restore disk.

Lucky. I think the last time I tried that, it didn't work because of the
way that HP locked the restore media to the BIOS identifier. Always
wanted to be able to have the Bochs bios have an idenfier setting
I coudl pass in so I could do something like that.

>  I did need my key from the bottom.  I hope this meets the EULA . 

Can't tell you if it meets the EULA. I picked up a key when a company
trashed a laptop that still had the key on the bottom. 

> My laptop did die last year and I have been wondering what I could do with that extra copy.

>  Will Qemu boot a .iso file like ubuntu?

Yes, it's a whole lot easrier than shuffling CD's and DVD's about.

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

* [Qemu-devel] (no subject)
@ 2007-03-02 16:10 jeremy fenelon
  0 siblings, 0 replies; 133+ messages in thread
From: jeremy fenelon @ 2007-03-02 16:10 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

Hey guys thanks for a great product. I don't know if its been documented already but I was able to install windows xp  on qemu with a HP Laptop Restore disk.
 I did need my key from the bottom.  I hope this meets the EULA . My laptop did die last year and I have been wondering what I could do with that extra copy.
 
 Will Qemu boot a .iso file like ubuntu?
 Thank

[-- Attachment #2: Type: text/html, Size: 387 bytes --]

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

* [Qemu-devel] (no subject)
@ 2006-11-21 16:08  Torbjörn Andersson
  0 siblings, 0 replies; 133+ messages in thread
From:  Torbjörn Andersson @ 2006-11-21 16:08 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/html, Size: 1437 bytes --]

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

* RE: [Qemu-devel] (no subject)
  2006-10-07  5:51 av1474
@ 2006-10-10 20:50 ` Blue Swirl
  0 siblings, 0 replies; 133+ messages in thread
From: Blue Swirl @ 2006-10-10 20:50 UTC (permalink / raw)
  To: av1474; +Cc: qemu-devel

>For nearly 6 years on of the applications i wrote exhibited incorrect
>behavior on the systems running X with MSB byte/bit order. And today
>i finally nailed it down, all thanks to the work of Fabrice Bellard
>and Blue Swirl.

Thanks. Out of curiosity, how did you debug the software with Qemu? What was 
Qemu's advantage compared to real hardware?

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/

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

* [Qemu-devel] (no subject)
@ 2006-10-07  5:51 av1474
  2006-10-10 20:50 ` Blue Swirl
  0 siblings, 1 reply; 133+ messages in thread
From: av1474 @ 2006-10-07  5:51 UTC (permalink / raw)
  To: qemu-devel

Hello,

This is email is a small token of appreciation.

For nearly 6 years on of the applications i wrote exhibited incorrect
behavior on the systems running X with MSB byte/bit order. And today
i finally nailed it down, all thanks to the work of Fabrice Bellard
and Blue Swirl.

So.. Fabrice, Blue Swirl - THANK YOU.

Igor Kovalenko also deserves honorary mention.

The problem wasn't even in my code but third party library, oh well..

This also is a perfect opportunity to piggy back other piece of
information: if someone here wrote to malc@pulsesoft.com and never
got any reply please do resend the message(s) to the above address,
apparently the mail server at pulsesoft lost the ability to distinguish
spam from ham (and sadly it happened a long while ago).

--
maybe later

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

* [Qemu-devel] (no subject)
@ 2005-12-20 19:47 Hoppers U. Moppet
  0 siblings, 0 replies; 133+ messages in thread
From: Hoppers U. Moppet @ 2005-12-20 19:47 UTC (permalink / raw)
  To: Qemu

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

The new, easy way to order your prescvriptions!

Vlangra $3.3
Levirtra $3.3
Ciaelis $3.7
Imitrrex $16.4
Flomdax $2.2
Ultrkam $0.78
Viojxx $4.75
Ambfien $2.2
Valwium $0.97 
Xanqax $1.09
Sodma $3
Merildia $2.2 
and more other...

- We are proud to be able to bring you our wide selection of megdicines, all of them are available to you online, 24x7.
- No Waiting for Doctors, you will enjoy Complete privacy, and you can order anytime, in your Own time, with No prior prescriiption needed!
- Now you can enjoy the convenience of ordering from your own home or office at the time that suits you!
- Order Safely and Securely through our secure transaction server, and pay using a wide range of credit cards.

Visit our website 
http://poplaecte.com

WBR,
Online Pharmaceuticals
ertytyjiklg QFdeQRhVV0VRWXFcXFpSX0cdW0dW

[-- Attachment #2: Type: text/html, Size: 1109 bytes --]

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

* [Qemu-devel] (no subject)
@ 2005-11-08 15:57 Shahar Livne
  0 siblings, 0 replies; 133+ messages in thread
From: Shahar Livne @ 2005-11-08 15:57 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2 bytes --]



[-- Attachment #2: Type: text/html, Size: 6 bytes --]

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

* [Qemu-devel] (no subject)
@ 2005-11-03 13:16 Qemtz
  0 siblings, 0 replies; 133+ messages in thread
From: Qemtz @ 2005-11-03 13:16 UTC (permalink / raw)
  To: Qemu-devel

[-- Attachment #1: Type: text/html, Size: 48 bytes --]

[-- Attachment #2: Info_prices.zip --]
[-- Type: application/octet-stream, Size: 8256 bytes --]

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

* Re: [Qemu-devel] (no subject)
  2005-04-27 16:04 ` Johannes Schindelin
@ 2005-04-27 16:38   ` Alex Beregszaszi
  0 siblings, 0 replies; 133+ messages in thread
From: Alex Beregszaszi @ 2005-04-27 16:38 UTC (permalink / raw)
  To: qemu-devel

Hi,

> > my question is, can u implemet to read and write in a normal
> > direcktory-struckure for mounting in qemu normaly direktorys als
> > harddisks to direcktly changing div. files in the Orderingsystems
> > look there:
> >
> > [...]
> 
> I played with this idea last December. I even produced a patch to
> QEmu, implementing the VVFAT block driver. The read support was
> usable, but the write support was buggy. Unfortunately, I did not have
> time since then to play more.

Hey, I vote for committing with read-only support by default. So I can
remove an entry from my todo list :)

-- 
Alex Beregszaszi 			e-mail: alex@fsn.hu
Free Software Network			cell: +36 70 3144424

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

* Re: [Qemu-devel] (no subject)
  2005-04-27 14:08 blackcrack
@ 2005-04-27 16:04 ` Johannes Schindelin
  2005-04-27 16:38   ` Alex Beregszaszi
  0 siblings, 1 reply; 133+ messages in thread
From: Johannes Schindelin @ 2005-04-27 16:04 UTC (permalink / raw)
  To: blackcrack, qemu-devel

Hi,

On Wed, 27 Apr 2005, blackcrack wrote:

> my question is, can u implemet to read and write in a normal
> direcktory-struckure for mounting in qemu normaly direktorys als
> harddisks to direcktly changing div. files in the Orderingsystems look
> there:
>
> [...]

I played with this idea last December. I even produced a patch to QEmu,
implementing the VVFAT block driver. The read support was usable, but the
write support was buggy. Unfortunately, I did not have time since then to
play more.

Ciao,
Dscho

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

* [Qemu-devel] (no subject)
@ 2005-04-27 14:08 blackcrack
  2005-04-27 16:04 ` Johannes Schindelin
  0 siblings, 1 reply; 133+ messages in thread
From: blackcrack @ 2005-04-27 14:08 UTC (permalink / raw)
  To: qemu-devel

Hy,

my question is, can u implemet to read and write in a normal  
direcktory-struckure for mounting in qemu normaly direktorys als harddisks  
to
direcktly changing div. files in the Orderingsystems look there:

in Linux:
qemu -hda -fmt fat /home/user/win1   (;))
qemu -hda -fmt fat /home/user/win311
qemu -hda -fmt fat32 /home/user/win95-or-Me
qemu -hda -fmt ntfs /home/user/winnt

in windows:

qemu -hda -fmt fat C:\working\win311
qemu -hda -fmt fat32 C:\working\win95-or-Me
qemu -hda -fmt ntfs C:\working\winnt

if u cant use this idea not direcktly,..  you can
think about if you use direcktorys as slave partition
do changing the informations and files with the Guestos
to open Documents quickly in a other OS's
without network.. take a look:

qemu -hda /home/user/win95.img -hdb -fmt fat32  
/home/user/win95-or-Me-or-nt -cdrom /mnt/cdrom

to read and write dokumens on the 2nd emulate harddisk how read and write  
samba ;) but only in one account. the CDrom is read only as def. but is  
read fom a direcktory or a file....

i hope i have get you some ideas :)
kind regard
Blacky

blackysgate.de

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

* [Qemu-devel] (no subject)
@ 2005-01-18  4:44 Cliff
  0 siblings, 0 replies; 133+ messages in thread
From: Cliff @ 2005-01-18  4:44 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]

how can I boot the reactos-0.2.3.img under versions 0.6.1/0.6.2 under
windows host?
error is missing operating system
 
it boots under 0.6.0.

[-- Attachment #2: Type: text/html, Size: 741 bytes --]

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

* [Qemu-devel] (no subject)
@ 2004-08-08  1:42 anthony hill
  0 siblings, 0 replies; 133+ messages in thread
From: anthony hill @ 2004-08-08  1:42 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

Hi 
It's a shame the gdb stub does not work on MS Windows. I know some of the issues, like the names of the header files, are easily fixed, but I don't know what else would need to be done. 
Has anyone else tried to fix this? 
Is it fixable? And what other problems might I encounter?
Thanks 
Ant

[-- Attachment #2: Type: text/html, Size: 837 bytes --]

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

* [Qemu-devel] (no subject)
@ 2004-02-19 17:16 Adrian C
  0 siblings, 0 replies; 133+ messages in thread
From: Adrian C @ 2004-02-19 17:16 UTC (permalink / raw)
  To: qemu-devel



_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

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

end of thread, other threads:[~2019-02-26  6:25 UTC | newest]

Thread overview: 133+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-25 13:18 [Qemu-devel] (no subject) Yang Weijiang
2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 1/5] Add CET xsaves/xrstors related macros and structures Yang Weijiang
2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 2/5] Add CET SHSTK and IBT CPUID feature-word definitions Yang Weijiang
2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 3/5] Add hepler functions for CPUID xsave area size calculation Yang Weijiang
2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 4/5] Report CPUID xsave area support for CET Yang Weijiang
2019-02-25 13:18 ` [Qemu-devel] [PATCH v3 5/5] Add CET MSR save/restore support for migration Yang Weijiang
  -- strict thread matches above, loose matches on Subject: below --
2019-01-02  2:02 [Qemu-devel] (no subject) Yaowei Bai
2018-12-13 10:10 Илья Резников
2018-11-28  1:08 John Arbuckle
2018-11-28 19:39 ` Peter Maydell
2018-11-29  0:21   ` Programmingkid
2018-11-29  2:11     ` berkus infinitus
2018-11-29 10:18       ` Peter Maydell
2018-07-22  9:13 Liujinsong (Paul)
2018-06-20  7:32 [Qemu-devel] [PATCH v5 0/7] monitor: enable OOB by default Peter Xu
2018-06-26 17:21 ` [Qemu-devel] (no subject) Markus Armbruster
2017-10-12 23:54 Anatol Pomozov
2017-08-07 16:34 Eduardo Otubo
2017-08-07 13:31 vaibhav shukla
2017-05-17 22:42 John Bradley
2017-05-18  5:29 ` no-reply
2017-05-18  5:31 ` no-reply
     [not found] <CAMj-D2DO_CfvD77izsGfggoKP45HSC9aD6auUPAYC9Yeq_aX7w@mail.gmail.com>
2017-05-04 16:44 ` gengdongjiu
2017-03-21 14:03 [Qemu-devel] [PATCH] qemu-ga: add guest-get-osinfo command Vinzenz Feenstra
2017-03-16 14:50 ` [Qemu-devel] (no subject) Vinzenz 'evilissimo' Feenstra
2017-03-23 13:44   ` Eric Blake
2017-02-24 13:19 Eric Bischoff
2017-02-17 15:42 Pranith Kumar
2017-01-02 12:03 morgenlette madeBy
2017-01-03 16:36 ` Stefan Hajnoczi
2016-11-16 19:41 Christopher Oliver
2016-11-17  9:15 ` Thomas Huth
2016-10-30 15:30 Pradeep Jagadeesh
2016-10-20  6:59 Nicholas Piggin
2016-10-12 21:49 Neeraj Sharma
2016-10-02  6:47 Shreya Shrivastava
2016-09-12 21:23 Stephen Bates
2016-09-13  2:28 ` Fam Zheng
2016-09-19 15:54   ` Stephen Bates
2016-07-31 15:07 Kumud Bhat
2016-03-21  8:44 Yunqiang Gao
2016-03-21 18:00 ` John Snow
2016-03-21 21:09   ` Peter Maydell
2016-03-22 21:45     ` John Snow
2016-01-15 10:06 Liang Li
2015-11-17 13:08 Christoph Hellwig
2015-11-17 17:29 ` Paolo Bonzini
2015-07-14  7:33 Pankaj Gupta
2015-07-02 16:18 Denis V. Lunev
2015-06-30  4:49 Scott Feldman
2015-06-30  7:18 ` Fam Zheng
2015-06-30 14:22   ` Scott Feldman
2015-05-03 14:10 yhindin
2015-05-03 14:10 yhindin
2015-05-03 14:10 yhindin
2015-05-03 14:07 yhindin
2015-05-03 14:07 yhindin
2015-02-22  1:00 Sunil Kumar
2014-12-06 10:54 Jun Li
2014-11-10  3:14 xubin yan
2014-09-17 16:20 Priyanka Ranjan
2014-06-12 14:45 Puneet Bakshi
2014-02-04 14:18 Валентин Сайков
2013-11-21 19:33 [Qemu-devel] [PATCH for-1.7 0/5] acpi unit-test: added tests Marcel Apfelbaum
2013-11-21 19:33 ` [Qemu-devel] [PATCH for-1.7 2/5] acpi unit-test: adjust the test data structure for better handling Marcel Apfelbaum
2013-12-10 16:42   ` [Qemu-devel] (no subject) Michael S. Tsirkin
2013-08-18 18:19 Liu, Jinsong
2013-05-06 13:47 [Qemu-devel] [PATCH] Add 'maxqdepth' as an option to tty character devices Paolo Bonzini
2013-05-07 16:36 ` [Qemu-devel] (no subject) John Baboval
2013-04-02 16:02 Elizabeth Brown
2013-04-05  7:18 ` Stefan Hajnoczi
2012-11-19 20:39 Stefan Priebe
2012-07-23 10:59 Paulo Arcinas
2012-07-20  3:39 Guan Xuetao
2012-04-01 16:19 César
2012-03-08  3:26 suyi wang
     [not found] <[0/4] RESEND: Outstanding bugfixes and cleanups>
2012-03-08  0:41 ` David Gibson
2012-02-29 12:43 Dmitry Fleytman
2011-12-29 21:17 Fred Oliveira
2011-12-13  2:50 Erik Lotspeich
2011-12-13  8:06 ` Stefan Hajnoczi
2011-12-13 12:55   ` Erik Lotspeich
2011-12-13 14:57     ` Stefan Hajnoczi
2011-12-13 15:22       ` Erik Lotspeich
2011-12-13 15:56         ` Paolo Bonzini
2011-12-08 12:06 wong
2011-11-11 21:46 Ronnie Sahlberg
2011-10-24 21:03 Benoît Canet
2011-10-24 10:25 王永博
2011-09-29 16:55 Ottavio
2011-09-14 14:38 王永博
2011-08-03 14:50 Michael Tokarev
2011-06-12  2:47 Ronnie Sahlberg
2011-05-31  4:56 coolman coolx
2011-03-08  9:59 Stefan Hajnoczi
2011-02-17 10:45 maheen butt
2011-01-04 15:15 Aurelien Jarno
2011-01-04 16:06 ` Peter Maydell
2011-01-04 16:12   ` Aurelien Jarno
2010-12-13  8:05 Ronnie Sahlberg
2010-12-06  0:39 Joao Francisco Medeiros Neto
2010-12-05 19:29 Joao Francisco Medeiros Neto
2010-12-02 18:21 Joao Francisco Medeiros Neto
2010-11-28 14:28 Joao Francisco Medeiros Neto
2010-11-27 16:37 Joao Francisco Medeiros Neto
2010-11-12  9:43 Stefan Hajnoczi
2010-11-11  1:30 Michael Roth
2010-10-31 11:17 Zamzit
2010-10-22 14:56 Stefan Hajnoczi
2010-05-18  7:31 Corentin Chary
2010-02-10 18:15 Stephen Isard
2009-10-31  1:07 Jason McMullan
2009-07-01 21:26 G 3
2009-03-17 20:37 Uri Lublin
2009-01-29 19:54 Uri Lublin
2009-01-30  2:43 ` Paul Brook
2009-02-01 15:20   ` Uri Lublin
2008-12-13 21:18 froydnj
2008-12-13 19:31 froydnj
2008-12-11 22:12 Hollis Blanchard
2008-12-11 22:43 ` Aurelien Jarno
2008-11-14 15:38 sniper
2008-08-21 14:27 Paweł Tulik
2007-04-10 13:34 Stuart Anderson
2007-03-03 23:09 Ben Taylor
2007-03-02 16:10 jeremy fenelon
2006-11-21 16:08  Torbjörn Andersson
2006-10-07  5:51 av1474
2006-10-10 20:50 ` Blue Swirl
2005-12-20 19:47 Hoppers U. Moppet
2005-11-08 15:57 Shahar Livne
2005-11-03 13:16 Qemtz
2005-04-27 14:08 blackcrack
2005-04-27 16:04 ` Johannes Schindelin
2005-04-27 16:38   ` Alex Beregszaszi
2005-01-18  4:44 Cliff
2004-08-08  1:42 anthony hill
2004-02-19 17:16 Adrian C

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.