summaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-07-14 13:44:06 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-07-14 13:44:06 +0100
commit190c93c98283e75e1a9e01babd1ec14624cb6204 (patch)
tree076088bb5b665d34db5920a1c3ca03071ae59289 /backends
parent9358450e98ed4a5350df4754863d116ff2e6186c (diff)
parent2aece63c8a9d2c3a8ff41d2febc4cdeff2633331 (diff)
downloadqemu-190c93c98283e75e1a9e01babd1ec14624cb6204.tar.gz
qemu-190c93c98283e75e1a9e01babd1ec14624cb6204.tar.bz2
qemu-190c93c98283e75e1a9e01babd1ec14624cb6204.zip
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* SCSI scanner support * fixes to qemu-char and net exit * FreeBSD fixes * Other small bugfixes # gpg: Signature made Wed 13 Jul 2016 12:30:11 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: hostmem: detect host backend memory is being used properly hostmem: fix QEMU crash by 'info memdev' char: do not use atexit cleanup handler net: do not use atexit for cleanup slirp: use exit notifier for slirp_smb_cleanup tap: use an exit notifier to call down_script util: Fix MIN_NON_ZERO qemu-sockets: use qapi_free_SocketAddress in cleanup disas: avoid including everything in headers compiled from C++ json-streamer: fix double-free on exiting during a parse main-loop: check return value before using pointer Use "-s" instead of "--quiet" to resolve non-fatal build error on FreeBSD. scsi-bus: Use longer sense buffer with scanners scsi-bus: Add SCSI scanner support Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'backends')
-rw-r--r--backends/hostmem.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 6e28be11eb..ac802570a8 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -64,6 +64,14 @@ out:
error_propagate(errp, local_err);
}
+static uint16List **host_memory_append_node(uint16List **node,
+ unsigned long value)
+{
+ *node = g_malloc0(sizeof(**node));
+ (*node)->value = value;
+ return &(*node)->next;
+}
+
static void
host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
@@ -74,25 +82,23 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
unsigned long value;
value = find_first_bit(backend->host_nodes, MAX_NODES);
+
+ node = host_memory_append_node(node, value);
+
if (value == MAX_NODES) {
- return;
+ goto out;
}
- *node = g_malloc0(sizeof(**node));
- (*node)->value = value;
- node = &(*node)->next;
-
do {
value = find_next_bit(backend->host_nodes, MAX_NODES, value + 1);
if (value == MAX_NODES) {
break;
}
- *node = g_malloc0(sizeof(**node));
- (*node)->value = value;
- node = &(*node)->next;
+ node = host_memory_append_node(node, value);
} while (true);
+out:
visit_type_uint16List(v, name, &host_nodes, errp);
}
@@ -258,6 +264,16 @@ host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp)
return memory_region_size(&backend->mr) ? &backend->mr : NULL;
}
+void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped)
+{
+ backend->is_mapped = mapped;
+}
+
+bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
+{
+ return backend->is_mapped;
+}
+
static void
host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
{
@@ -335,10 +351,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
static bool
host_memory_backend_can_be_deleted(UserCreatable *uc, Error **errp)
{
- MemoryRegion *mr;
-
- mr = host_memory_backend_get_memory(MEMORY_BACKEND(uc), errp);
- if (memory_region_is_mapped(mr)) {
+ if (host_memory_backend_is_mapped(MEMORY_BACKEND(uc))) {
return false;
} else {
return true;