qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com, Bharata B Rao <bharata@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v0 1/2] pc: Fix DIMMs capacity calculation
Date: Mon, 12 Jan 2015 09:32:33 +0530	[thread overview]
Message-ID: <1421035354-14721-2-git-send-email-bharata@linux.vnet.ibm.com> (raw)
In-Reply-To: <1421035354-14721-1-git-send-email-bharata@linux.vnet.ibm.com>

pc_existing_dimms_capacity() is returning DIMMs count rather than capacity.
Fix this to return the capacity. Also consider only realized devices for
capacity calculation.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 hw/i386/pc.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e07f1fa..125cf0a 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1552,25 +1552,18 @@ void qemu_register_pc_machine(QEMUMachine *m)
     g_free(name);
 }
 
-static int pc_dimm_count(Object *obj, void *opaque)
-{
-    int *count = opaque;
-
-    if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
-        (*count)++;
-    }
-
-    object_child_foreach(obj, pc_dimm_count, opaque);
-    return 0;
-}
-
 static int pc_existing_dimms_capacity(Object *obj, void *opaque)
 {
     Error *local_err = NULL;
     uint64_t *size = opaque;
 
     if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
-        (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &local_err);
+        DeviceState *dev = DEVICE(obj);
+
+        if (dev->realized) {
+            (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP,
+                &local_err);
+        }
 
         if (local_err) {
             qerror_report_err(local_err);
@@ -1579,7 +1572,7 @@ static int pc_existing_dimms_capacity(Object *obj, void *opaque)
         }
     }
 
-    object_child_foreach(obj, pc_dimm_count, opaque);
+    object_child_foreach(obj, pc_existing_dimms_capacity, opaque);
     return 0;
 }
 
@@ -1623,8 +1616,9 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     if (existing_dimms_capacity + memory_region_size(mr) >
         machine->maxram_size - machine->ram_size) {
         error_setg(&local_err, "not enough space, currently 0x%" PRIx64
-                   " in use of total 0x" RAM_ADDR_FMT,
-                   existing_dimms_capacity, machine->maxram_size);
+                   " in use of total hot pluggable 0x" RAM_ADDR_FMT,
+                   existing_dimms_capacity,
+                   machine->maxram_size - machine->ram_size);
         goto out;
     }
 
-- 
2.1.0

  reply	other threads:[~2015-01-12  4:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12  4:02 [Qemu-devel] [PATCH v0 0/2] Fix pc DIMMs capacity calculation Bharata B Rao
2015-01-12  4:02 ` Bharata B Rao [this message]
2015-01-20 10:14   ` [Qemu-devel] [PATCH v0 1/2] pc: Fix " Igor Mammedov
2015-01-12  4:02 ` [Qemu-devel] [PATCH v0 2/2] pc-dimm: Make pc_existing_dimms_capacity global Bharata B Rao
2015-01-20 10:18   ` Igor Mammedov
2015-01-21  8:58     ` Bharata B Rao
2015-01-21 10:38       ` Igor Mammedov
2015-01-22 14:34         ` Bharata B Rao
2015-01-22 15:00           ` Igor Mammedov
2015-01-20  3:21 ` [Qemu-devel] [PATCH v0 0/2] Fix pc DIMMs capacity calculation Bharata B Rao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421035354-14721-2-git-send-email-bharata@linux.vnet.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).