From 38a953a28ed140726743fa3bac2d03fdbb967978 Mon Sep 17 00:00:00 2001 From: Richard Gooch Date: Thu, 7 Feb 2019 07:01:48 -0800 Subject: [PATCH 1/5] Add permissions constants to lib/fsutil package. --- lib/fsutil/api.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/fsutil/api.go b/lib/fsutil/api.go index 8c0c6154..eeb09c13 100644 --- a/lib/fsutil/api.go +++ b/lib/fsutil/api.go @@ -5,11 +5,19 @@ import ( "hash" "io" "os" + "syscall" "time" "github.com/Symantec/Dominator/lib/log" ) +const ( + DirPerms = syscall.S_IRWXU | syscall.S_IRGRP | syscall.S_IXGRP | + syscall.S_IROTH | syscall.S_IXOTH + PrivateFilePerms = syscall.S_IRUSR | syscall.S_IWUSR + PublicFilePerms = PrivateFilePerms | syscall.S_IRGRP | syscall.S_IROTH +) + var ( ErrorChecksumMismatch = errors.New("checksum mismatch") ) From 6f95bd3ed46c1c0dd275b63fd22ab3b95cda6530 Mon Sep 17 00:00:00 2001 From: Richard Gooch Date: Fri, 8 Feb 2019 06:48:27 -0800 Subject: [PATCH 2/5] Log destination hypervisor in vm-control when migrating or copying VM. --- cmd/vm-control/copyVm.go | 1 + cmd/vm-control/migrateVm.go | 1 + 2 files changed, 2 insertions(+) diff --git a/cmd/vm-control/copyVm.go b/cmd/vm-control/copyVm.go index ea4088de..de9e9479 100644 --- a/cmd/vm-control/copyVm.go +++ b/cmd/vm-control/copyVm.go @@ -89,6 +89,7 @@ func copyVmFromHypervisor(sourceHypervisorAddress string, vmIP net.IP, SourceHypervisor: sourceHypervisorAddress, } var reply hyper_proto.CopyVmResponse + logger.Debugf(0, "copying VM to %s\n", destHypervisorAddress) if err := callCopyVm(destHypervisor, request, &reply, logger); err != nil { return err } diff --git a/cmd/vm-control/migrateVm.go b/cmd/vm-control/migrateVm.go index ff50a630..b25f2915 100644 --- a/cmd/vm-control/migrateVm.go +++ b/cmd/vm-control/migrateVm.go @@ -71,6 +71,7 @@ func migrateVmFromHypervisor(sourceHypervisorAddress string, vmIP net.IP, return err } defer destHypervisor.Close() + logger.Debugf(0, "migrating VM to %s\n", destHypervisorAddress) conn, err := destHypervisor.Call("Hypervisor.MigrateVm") if err != nil { return err From 6cddd2d1175e7c1ce7c49f19f18f223d8292f636 Mon Sep 17 00:00:00 2001 From: Richard Gooch Date: Sat, 9 Feb 2019 06:36:52 -0800 Subject: [PATCH 3/5] Change Hypervisor.CopyVm SRPC method to always leave new VM in stopped state. --- hypervisor/manager/vm.go | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/hypervisor/manager/vm.go b/hypervisor/manager/vm.go index 7eeb038f..117910ac 100644 --- a/hypervisor/manager/vm.go +++ b/hypervisor/manager/vm.go @@ -346,15 +346,18 @@ func (m *Manager) copyVm(conn *srpc.Conn, request proto.CopyVmRequest, if err != nil { return err } + switch getInfoReply.VmInfo.State { + case proto.StateStopped, proto.StateRunning: + default: + return errors.New("VM is not stopped or running") + } accessToken := request.AccessToken vmInfo := getInfoReply.VmInfo vmInfo.Address = proto.Address{} vmInfo.SecondaryAddresses = nil vmInfo.Uncommitted = false - vm, err := m.allocateVm(proto.CreateVmRequest{ - DhcpTimeout: request.DhcpTimeout, - VmInfo: vmInfo, - }, conn.GetAuthInformation()) + vm, err := m.allocateVm(proto.CreateVmRequest{VmInfo: vmInfo}, + conn.GetAuthInformation()) vm.OwnerUsers = getInfoReply.VmInfo.OwnerUsers vm.Volumes = vmInfo.Volumes if err := <-tryAllocateMemory(vmInfo.MemoryInMiB); err != nil { @@ -376,9 +379,6 @@ func (m *Manager) copyVm(conn *srpc.Conn, request proto.CopyVmRequest, return } vm.cleanup() - if getInfoReply.VmInfo.State == proto.StateRunning { - hyperclient.StartVm(hypervisor, request.IpAddress, accessToken) - } }() vm.ownerUsers = make(map[string]struct{}, len(vm.OwnerUsers)) for _, username := range vm.OwnerUsers { @@ -406,6 +406,7 @@ func (m *Manager) copyVm(conn *srpc.Conn, request proto.CopyVmRequest, if err != nil { return err } + defer hyperclient.StartVm(hypervisor, request.IpAddress, accessToken) err = sendVmCopyMessage(conn, encoder, "update volume(s)") if err != nil { return err @@ -420,18 +421,11 @@ func (m *Manager) copyVm(conn *srpc.Conn, request proto.CopyVmRequest, if err != nil { return err } - if err := sendVmCopyMessage(conn, encoder, "starting VM"); err != nil { - return err - } - dhcpTimedOut, err := vm.startManaging(request.DhcpTimeout, false) - if err != nil { - return err - } + vm.setState(proto.StateStopped) vm.destroyTimer = time.AfterFunc(time.Second*15, vm.autoDestroy) response := proto.CopyVmResponse{ - DhcpTimedOut: dhcpTimedOut, - Final: true, - IpAddress: vm.Address.IpAddress, + Final: true, + IpAddress: vm.Address.IpAddress, } if err := encoder.Encode(response); err != nil { return err From 86c5a0656050ca5ead9ba675c58998149411824e Mon Sep 17 00:00:00 2001 From: Richard Gooch Date: Sun, 10 Feb 2019 09:57:24 -0800 Subject: [PATCH 4/5] Remove obsolete DHCP checks and probes from vm-control copy-vm subcommand. --- cmd/vm-control/copyVm.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd/vm-control/copyVm.go b/cmd/vm-control/copyVm.go index de9e9479..83e6fdb8 100644 --- a/cmd/vm-control/copyVm.go +++ b/cmd/vm-control/copyVm.go @@ -84,7 +84,6 @@ func copyVmFromHypervisor(sourceHypervisorAddress string, vmIP net.IP, defer destHypervisor.Close() request := hyper_proto.CopyVmRequest{ AccessToken: accessToken, - DhcpTimeout: *dhcpTimeout, IpAddress: vmIP, SourceHypervisor: sourceHypervisorAddress, } @@ -97,12 +96,5 @@ func copyVmFromHypervisor(sourceHypervisorAddress string, vmIP net.IP, return fmt.Errorf("error acknowledging VM: %s", err) } fmt.Println(reply.IpAddress) - if reply.DhcpTimedOut { - return errors.New("DHCP ACK timed out") - } - if *dhcpTimeout > 0 { - logger.Debugln(0, "Received DHCP ACK") - } - return maybeWatchVm(destHypervisor, destHypervisorAddress, reply.IpAddress, - logger) + return nil } From 6e0ecea923cded5af5cd8e484c42e9b1196b750c Mon Sep 17 00:00:00 2001 From: Richard Gooch Date: Mon, 11 Feb 2019 07:37:14 -0800 Subject: [PATCH 5/5] Remove obsolete DHCP-related fields in proto/hypervisor.CopyVm messages. --- proto/hypervisor/messages.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/proto/hypervisor/messages.go b/proto/hypervisor/messages.go index 9c2b9d71..1421e19c 100644 --- a/proto/hypervisor/messages.go +++ b/proto/hypervisor/messages.go @@ -97,13 +97,11 @@ type CommitImportedVmResponse struct { type CopyVmRequest struct { AccessToken []byte - DhcpTimeout time.Duration IpAddress net.IP SourceHypervisor string } type CopyVmResponse struct { // Multiple responses are sent. - DhcpTimedOut bool Error string Final bool // If true, this is the final response. IpAddress net.IP