]> git.proxmox.com Git - qemu.git/commitdiff
Merge commit 'mst/pci' into staging
authorAnthony Liguori <aliguori@us.ibm.com>
Mon, 7 Dec 2009 20:31:38 +0000 (14:31 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 7 Dec 2009 20:31:38 +0000 (14:31 -0600)
monitor.c
qemu-monitor.hx
qerror.c
qerror.h
target-i386/helper.c
target-i386/kvm.c

index ba76f3416d611e4abd71a9b44b75c23228c36e08..27c696b2d4298c8d9855de7141c46e8f47496616 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -772,6 +772,22 @@ static void do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
     eject_device(mon, bs, force);
 }
 
+static void do_block_set_passwd(Monitor *mon, const QDict *qdict,
+                                QObject **ret_data)
+{
+    BlockDriverState *bs;
+
+    bs = bdrv_find(qdict_get_str(qdict, "device"));
+    if (!bs) {
+        qemu_error_new(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device"));
+        return;
+    }
+
+    if (bdrv_set_key(bs, qdict_get_str(qdict, "password")) < 0) {
+        qemu_error_new(QERR_INVALID_PASSWORD);
+    }
+}
+
 static void do_change_block(Monitor *mon, const char *device,
                             const char *filename, const char *fmt)
 {
index 62e395bffd6d087f96ca3cea4f7313069e57f8c7..c2670ee1d96c27a990f04f3cdd61f7914d56fdc3 100644 (file)
@@ -1045,6 +1045,20 @@ STEXI
 Close the file descriptor previously assigned to @var{fdname} using the
 @code{getfd} command. This is only needed if the file descriptor was never
 used by another monitor command.
+ETEXI
+
+    {
+        .name       = "block_passwd",
+        .args_type  = "device:B,password:s",
+        .params     = "block_passwd device password",
+        .help       = "set the password of encrypted block devices",
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_block_set_passwd,
+    },
+
+STEXI
+@item block_passwd @var{device} @var{password}
+Set the encrypted device @var{device} password to @var{password}
 ETEXI
 
 STEXI
index d00e5347e1fdb87666c1c761ea581cf5c74e78dc..eb4ce333123ef6fbb162cc7ff8d6bc19f35e2ae0 100644 (file)
--- a/qerror.c
+++ b/qerror.c
@@ -56,6 +56,10 @@ static const QErrorStringTable qerror_table[] = {
         .error_fmt   = QERR_INVALID_PARAMETER_TYPE,
         .desc        = "Invalid parameter type, expected: %(expected)",
     },
+    {
+        .error_fmt   = QERR_INVALID_PASSWORD,
+        .desc        = "The entered password is invalid",
+    },
     {
         .error_fmt = QERR_KVM_MISSING_CAP,
         .desc      = "Using KVM without %(capability), %(feature) unavailable",
index 5fd993146336b3cb3b15c15507066071ab68cd55..5198adf14c5fa1da66f8eb5ce22d9a649dfaa312 100644 (file)
--- a/qerror.h
+++ b/qerror.h
@@ -50,6 +50,9 @@ QError *qobject_to_qerror(const QObject *obj);
 #define QERR_INVALID_PARAMETER_TYPE \
         "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
 
+#define QERR_INVALID_PASSWORD \
+        "{ 'class': 'InvalidPassword', 'data': {} }"
+
 #define QERR_KVM_MISSING_CAP \
         "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
 
index 957b3fc1f2a2491d62ceb9b293885e374c910aa7..08e6d6c39680d25768a7d2e349a039055c6d68ee 100644 (file)
@@ -1638,6 +1638,24 @@ static void host_cpuid(uint32_t function, uint32_t count,
 #endif
 }
 
+static void get_cpuid_vendor(CPUX86State *env, uint32_t *ebx,
+                             uint32_t *ecx, uint32_t *edx)
+{
+    *ebx = env->cpuid_vendor1;
+    *edx = env->cpuid_vendor2;
+    *ecx = env->cpuid_vendor3;
+
+    /* sysenter isn't supported on compatibility mode on AMD, syscall
+     * isn't supported in compatibility mode on Intel.
+     * Normally we advertise the actual cpu vendor, but you can override
+     * this if you want to use KVM's sysenter/syscall emulation
+     * in compatibility mode and when doing cross vendor migration
+     */
+    if (kvm_enabled() && env->cpuid_vendor_override) {
+        host_cpuid(0, 0, NULL, ebx, ecx, edx);
+    }
+}
+
 void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx)
@@ -1654,16 +1672,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
     switch(index) {
     case 0:
         *eax = env->cpuid_level;
-        *ebx = env->cpuid_vendor1;
-        *edx = env->cpuid_vendor2;
-        *ecx = env->cpuid_vendor3;
-
-        /* sysenter isn't supported on compatibility mode on AMD.  and syscall
-         * isn't supported in compatibility mode on Intel.  so advertise the
-         * actuall cpu, and say goodbye to migration between different vendors
-         * is you use compatibility mode. */
-        if (kvm_enabled() && !env->cpuid_vendor_override)
-            host_cpuid(0, 0, NULL, ebx, ecx, edx);
+        get_cpuid_vendor(env, ebx, ecx, edx);
         break;
     case 1:
         *eax = env->cpuid_version;
@@ -1759,11 +1768,18 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ecx = env->cpuid_ext3_features;
         *edx = env->cpuid_ext2_features;
 
-        if (env->nr_cores * env->nr_threads > 1 &&
-            env->cpuid_vendor1 == CPUID_VENDOR_AMD_1 &&
-            env->cpuid_vendor2 == CPUID_VENDOR_AMD_2 &&
-            env->cpuid_vendor3 == CPUID_VENDOR_AMD_3) {
-            *ecx |= 1 << 1;    /* CmpLegacy bit */
+        /* The Linux kernel checks for the CMPLegacy bit and
+         * discards multiple thread information if it is set.
+         * So dont set it here for Intel to make Linux guests happy.
+         */
+        if (env->nr_cores * env->nr_threads > 1) {
+            uint32_t tebx, tecx, tedx;
+            get_cpuid_vendor(env, &tebx, &tecx, &tedx);
+            if (tebx != CPUID_VENDOR_INTEL_1 ||
+                tedx != CPUID_VENDOR_INTEL_2 ||
+                tecx != CPUID_VENDOR_INTEL_3) {
+                *ecx |= 1 << 1;    /* CmpLegacy bit */
+            }
         }
 
         if (kvm_enabled()) {
index 3b61a7fc5de3b653e45dfc56caf3030d2cf8e807..88b504c34ec82cba350e9e12d5dd179397b2936b 100644 (file)
@@ -244,9 +244,9 @@ static int kvm_has_msr_star(CPUState *env)
          * save/restore */
         msr_list.nmsrs = 0;
         ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);
-        if (ret < 0)
+        if (ret < 0 && ret != -E2BIG) {
             return 0;
-
+        }
         /* Old kernel modules had a bug and could write beyond the provided
            memory. Allocate at least a safe amount of 1K. */
         kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +