Merge pull request #96 from ganeshmaharaj/mem-hotplug-share

Allow sharing of memory backend file
This commit is contained in:
Julio Montes
2019-06-18 12:18:17 -05:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

@@ -1285,7 +1285,7 @@ func (q *QMP) ExecQueryCpusFast(ctx context.Context) ([]CPUInfoFast, error) {
} }
// ExecHotplugMemory adds size of MiB memory to the guest // ExecHotplugMemory adds size of MiB memory to the guest
func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string, size int) error { func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string, size int, share bool) error {
props := map[string]interface{}{"size": uint64(size) << 20} props := map[string]interface{}{"size": uint64(size) << 20}
args := map[string]interface{}{ args := map[string]interface{}{
"qom-type": qomtype, "qom-type": qomtype,
@@ -1295,6 +1295,9 @@ func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string
if mempath != "" { if mempath != "" {
props["mem-path"] = mempath props["mem-path"] = mempath
} }
if share {
props["share"] = true
}
err := q.executeCommand(ctx, "object-add", args, nil) err := q.executeCommand(ctx, "object-add", args, nil)
if err != nil { if err != nil {
return err return err

View File

@@ -1273,7 +1273,7 @@ func TestExecHotplugMemory(t *testing.T) {
cfg := QMPConfig{Logger: qmpTestLogger{}} cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh) q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh) checkVersion(t, connectedCh)
err := q.ExecHotplugMemory(context.Background(), "memory-backend-ram", "mem0", "", 128) err := q.ExecHotplugMemory(context.Background(), "memory-backend-ram", "mem0", "", 128, true)
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v\n", err) t.Fatalf("Unexpected error: %v\n", err)
} }