From c3eb7c4d60b53d67c259af9f7a63e91b07218bda Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Tue, 25 Apr 2017 22:06:42 +0800 Subject: [PATCH] add dax support Signed-off-by: Lai Jiangshan --- api/descriptions.pb.go | 537 +++++---------------------------- api/descriptions.proto | 1 + hack/update-generated-proto.sh | 2 +- hypervisor/context.go | 10 + hypervisor/disk.go | 10 +- hypervisor/libvirt/libvirt.go | 29 +- hypervisor/persistence.go | 2 + hypervisor/qemu/qemu.go | 58 +++- hypervisor/qemu/qemu_amd64.go | 2 +- hypervisor/qemu/qmp_wrapper.go | 28 -- 10 files changed, 179 insertions(+), 500 deletions(-) diff --git a/api/descriptions.pb.go b/api/descriptions.pb.go index 98f5c843..cbfc49e3 100644 --- a/api/descriptions.pb.go +++ b/api/descriptions.pb.go @@ -1,5 +1,6 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. +// Code generated by protoc-gen-go. // source: descriptions.proto +// DO NOT EDIT! /* Package api is a generated protocol buffer package. @@ -51,20 +52,6 @@ func (m *SandboxConfig) String() string { return proto.CompactTextStr func (*SandboxConfig) ProtoMessage() {} func (*SandboxConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (m *SandboxConfig) GetHostname() string { - if m != nil { - return m.Hostname - } - return "" -} - -func (m *SandboxConfig) GetDns() []string { - if m != nil { - return m.Dns - } - return nil -} - func (m *SandboxConfig) GetNeighbors() *NeighborNetworks { if m != nil { return m.Neighbors @@ -72,20 +59,6 @@ func (m *SandboxConfig) GetNeighbors() *NeighborNetworks { return nil } -func (m *SandboxConfig) GetDnsOptions() []string { - if m != nil { - return m.DnsOptions - } - return nil -} - -func (m *SandboxConfig) GetDnsSearch() []string { - if m != nil { - return m.DnsSearch - } - return nil -} - type ContainerDescription struct { Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` // Static Info, got from client input @@ -116,27 +89,6 @@ func (m *ContainerDescription) String() string { return proto.Compact func (*ContainerDescription) ProtoMessage() {} func (*ContainerDescription) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } -func (m *ContainerDescription) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *ContainerDescription) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *ContainerDescription) GetImage() string { - if m != nil { - return m.Image - } - return "" -} - func (m *ContainerDescription) GetLabels() map[string]string { if m != nil { return m.Labels @@ -144,20 +96,6 @@ func (m *ContainerDescription) GetLabels() map[string]string { return nil } -func (m *ContainerDescription) GetTty() bool { - if m != nil { - return m.Tty - } - return false -} - -func (m *ContainerDescription) GetStopSignal() string { - if m != nil { - return m.StopSignal - } - return "" -} - func (m *ContainerDescription) GetRootVolume() *VolumeDescription { if m != nil { return m.RootVolume @@ -165,20 +103,6 @@ func (m *ContainerDescription) GetRootVolume() *VolumeDescription { return nil } -func (m *ContainerDescription) GetMountId() string { - if m != nil { - return m.MountId - } - return "" -} - -func (m *ContainerDescription) GetRootPath() string { - if m != nil { - return m.RootPath - } - return "" -} - func (m *ContainerDescription) GetUGI() *UserGroupInfo { if m != nil { return m.UGI @@ -193,27 +117,6 @@ func (m *ContainerDescription) GetEnvs() map[string]string { return nil } -func (m *ContainerDescription) GetWorkdir() string { - if m != nil { - return m.Workdir - } - return "" -} - -func (m *ContainerDescription) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -func (m *ContainerDescription) GetArgs() []string { - if m != nil { - return m.Args - } - return nil -} - func (m *ContainerDescription) GetRlimits() []*Rlimit { if m != nil { return m.Rlimits @@ -235,13 +138,6 @@ func (m *ContainerDescription) GetVolumes() map[string]*VolumeReference { return nil } -func (m *ContainerDescription) GetInitialize() bool { - if m != nil { - return m.Initialize - } - return false -} - type VolumeDescription struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Source string `protobuf:"bytes,2,opt,name=source" json:"source,omitempty"` @@ -257,34 +153,6 @@ func (m *VolumeDescription) String() string { return proto.CompactTex func (*VolumeDescription) ProtoMessage() {} func (*VolumeDescription) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } -func (m *VolumeDescription) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *VolumeDescription) GetSource() string { - if m != nil { - return m.Source - } - return "" -} - -func (m *VolumeDescription) GetFormat() string { - if m != nil { - return m.Format - } - return "" -} - -func (m *VolumeDescription) GetFstype() string { - if m != nil { - return m.Fstype - } - return "" -} - func (m *VolumeDescription) GetOptions() *VolumeOption { if m != nil { return m.Options @@ -292,20 +160,6 @@ func (m *VolumeDescription) GetOptions() *VolumeOption { return nil } -func (m *VolumeDescription) GetDockerVolume() bool { - if m != nil { - return m.DockerVolume - } - return false -} - -func (m *VolumeDescription) GetReadOnly() bool { - if m != nil { - return m.ReadOnly - } - return false -} - type InterfaceDescription struct { Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` Lo bool `protobuf:"varint,2,opt,name=lo" json:"lo,omitempty"` @@ -322,62 +176,6 @@ func (m *InterfaceDescription) String() string { return proto.Compact func (*InterfaceDescription) ProtoMessage() {} func (*InterfaceDescription) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } -func (m *InterfaceDescription) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *InterfaceDescription) GetLo() bool { - if m != nil { - return m.Lo - } - return false -} - -func (m *InterfaceDescription) GetBridge() string { - if m != nil { - return m.Bridge - } - return "" -} - -func (m *InterfaceDescription) GetIp() string { - if m != nil { - return m.Ip - } - return "" -} - -func (m *InterfaceDescription) GetMac() string { - if m != nil { - return m.Mac - } - return "" -} - -func (m *InterfaceDescription) GetGw() string { - if m != nil { - return m.Gw - } - return "" -} - -func (m *InterfaceDescription) GetTapName() string { - if m != nil { - return m.TapName - } - return "" -} - -func (m *InterfaceDescription) GetOptions() string { - if m != nil { - return m.Options - } - return "" -} - type PortDescription struct { HostPort int32 `protobuf:"varint,1,opt,name=hostPort" json:"hostPort,omitempty"` ContainerPort int32 `protobuf:"varint,2,opt,name=containerPort" json:"containerPort,omitempty"` @@ -389,27 +187,6 @@ func (m *PortDescription) String() string { return proto.CompactTextS func (*PortDescription) ProtoMessage() {} func (*PortDescription) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } -func (m *PortDescription) GetHostPort() int32 { - if m != nil { - return m.HostPort - } - return 0 -} - -func (m *PortDescription) GetContainerPort() int32 { - if m != nil { - return m.ContainerPort - } - return 0 -} - -func (m *PortDescription) GetProtocol() string { - if m != nil { - return m.Protocol - } - return "" -} - type NeighborNetworks struct { InternalNetworks []string `protobuf:"bytes,1,rep,name=internalNetworks" json:"internalNetworks,omitempty"` ExternalNetworks []string `protobuf:"bytes,2,rep,name=externalNetworks" json:"externalNetworks,omitempty"` @@ -420,20 +197,6 @@ func (m *NeighborNetworks) String() string { return proto.CompactText func (*NeighborNetworks) ProtoMessage() {} func (*NeighborNetworks) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } -func (m *NeighborNetworks) GetInternalNetworks() []string { - if m != nil { - return m.InternalNetworks - } - return nil -} - -func (m *NeighborNetworks) GetExternalNetworks() []string { - if m != nil { - return m.ExternalNetworks - } - return nil -} - type VolumeReference struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` MountPoints []*VolumeMount `protobuf:"bytes,2,rep,name=mountPoints" json:"mountPoints,omitempty"` @@ -444,13 +207,6 @@ func (m *VolumeReference) String() string { return proto.CompactTextS func (*VolumeReference) ProtoMessage() {} func (*VolumeReference) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } -func (m *VolumeReference) GetName() string { - if m != nil { - return m.Name - } - return "" -} - func (m *VolumeReference) GetMountPoints() []*VolumeMount { if m != nil { return m.MountPoints @@ -468,26 +224,13 @@ func (m *VolumeMount) String() string { return proto.CompactTextStrin func (*VolumeMount) ProtoMessage() {} func (*VolumeMount) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } -func (m *VolumeMount) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -func (m *VolumeMount) GetReadOnly() bool { - if m != nil { - return m.ReadOnly - } - return false -} - type VolumeOption struct { User string `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"` Monitors []string `protobuf:"bytes,2,rep,name=monitors" json:"monitors,omitempty"` Keyring string `protobuf:"bytes,3,opt,name=keyring" json:"keyring,omitempty"` BytesPerSec int32 `protobuf:"varint,4,opt,name=bytesPerSec" json:"bytesPerSec,omitempty"` Iops int32 `protobuf:"varint,5,opt,name=iops" json:"iops,omitempty"` + DaxBlock bool `protobuf:"varint,6,opt,name=daxBlock" json:"daxBlock,omitempty"` } func (m *VolumeOption) Reset() { *m = VolumeOption{} } @@ -495,41 +238,6 @@ func (m *VolumeOption) String() string { return proto.CompactTextStri func (*VolumeOption) ProtoMessage() {} func (*VolumeOption) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } -func (m *VolumeOption) GetUser() string { - if m != nil { - return m.User - } - return "" -} - -func (m *VolumeOption) GetMonitors() []string { - if m != nil { - return m.Monitors - } - return nil -} - -func (m *VolumeOption) GetKeyring() string { - if m != nil { - return m.Keyring - } - return "" -} - -func (m *VolumeOption) GetBytesPerSec() int32 { - if m != nil { - return m.BytesPerSec - } - return 0 -} - -func (m *VolumeOption) GetIops() int32 { - if m != nil { - return m.Iops - } - return 0 -} - type UserGroupInfo struct { User string `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"` Group string `protobuf:"bytes,2,opt,name=group" json:"group,omitempty"` @@ -541,27 +249,6 @@ func (m *UserGroupInfo) String() string { return proto.CompactTextStr func (*UserGroupInfo) ProtoMessage() {} func (*UserGroupInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } -func (m *UserGroupInfo) GetUser() string { - if m != nil { - return m.User - } - return "" -} - -func (m *UserGroupInfo) GetGroup() string { - if m != nil { - return m.Group - } - return "" -} - -func (m *UserGroupInfo) GetAdditionalGroups() []string { - if m != nil { - return m.AdditionalGroups - } - return nil -} - type Rlimit struct { Type string `protobuf:"bytes,1,opt,name=type" json:"type,omitempty"` Hard uint64 `protobuf:"varint,2,opt,name=hard" json:"hard,omitempty"` @@ -573,27 +260,6 @@ func (m *Rlimit) String() string { return proto.CompactTextString(m) func (*Rlimit) ProtoMessage() {} func (*Rlimit) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } -func (m *Rlimit) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *Rlimit) GetHard() uint64 { - if m != nil { - return m.Hard - } - return 0 -} - -func (m *Rlimit) GetSoft() uint64 { - if m != nil { - return m.Soft - } - return 0 -} - type Process struct { Container string `protobuf:"bytes,1,opt,name=Container" json:"Container,omitempty"` Id string `protobuf:"bytes,2,opt,name=Id" json:"Id,omitempty"` @@ -611,69 +277,6 @@ func (m *Process) String() string { return proto.CompactTextString(m) func (*Process) ProtoMessage() {} func (*Process) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } -func (m *Process) GetContainer() string { - if m != nil { - return m.Container - } - return "" -} - -func (m *Process) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Process) GetUser() string { - if m != nil { - return m.User - } - return "" -} - -func (m *Process) GetGroup() string { - if m != nil { - return m.Group - } - return "" -} - -func (m *Process) GetAdditionalGroup() []string { - if m != nil { - return m.AdditionalGroup - } - return nil -} - -func (m *Process) GetTerminal() bool { - if m != nil { - return m.Terminal - } - return false -} - -func (m *Process) GetArgs() []string { - if m != nil { - return m.Args - } - return nil -} - -func (m *Process) GetEnvs() []string { - if m != nil { - return m.Envs - } - return nil -} - -func (m *Process) GetWorkdir() string { - if m != nil { - return m.Workdir - } - return "" -} - func init() { proto.RegisterType((*SandboxConfig)(nil), "api.SandboxConfig") proto.RegisterType((*ContainerDescription)(nil), "api.ContainerDescription") @@ -692,71 +295,71 @@ func init() { func init() { proto.RegisterFile("descriptions.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1050 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0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f, 0x25, 0xf0, 0xe0, 0x56, - 0x07, 0xb7, 0x83, 0x98, 0x74, 0x06, 0xf1, 0x21, 0x6c, 0x7b, 0xbb, 0x72, 0x79, 0xe3, 0x56, 0xe4, - 0x10, 0x9f, 0x5b, 0xb7, 0x94, 0x21, 0x4e, 0x68, 0xe4, 0x08, 0xf7, 0x61, 0x5d, 0x29, 0xde, 0x8b, - 0x38, 0x71, 0xec, 0x4b, 0x18, 0xd8, 0xb8, 0x48, 0x86, 0xe4, 0xe3, 0x83, 0x8e, 0x8f, 0xf5, 0x42, - 0x11, 0x8d, 0x04, 0xcb, 0xe0, 0x5e, 0x61, 0xf3, 0x0b, 0xe5, 0xe2, 0xe0, 0x8d, 0xa8, 0x82, 0x37, - 0x30, 0x1a, 0x24, 0x25, 0x8b, 0x53, 0x53, 0xae, 0x69, 0x62, 0x86, 0xa2, 0xe5, 0xb3, 0x3f, 0x13, - 0xd8, 0x9f, 0x98, 0xa0, 0xdc, 0x5c, 0xe6, 0xea, 0xdf, 0x56, 0xcf, 0x7d, 0x48, 0x4b, 0x4b, 0x91, - 0x0d, 0x45, 0x5a, 0x5a, 0xf4, 0x7e, 0xe6, 0x74, 0xd1, 0xee, 0x9d, 0xc8, 0x91, 0x5e, 0x15, 0x23, - 0x4a, 0x75, 0x85, 0x15, 0x58, 0xca, 0x9c, 0x36, 0xc9, 0x48, 0x20, 0x89, 0x12, 0x8b, 0xab, 0xb8, - 0x41, 0xd2, 0xc5, 0x15, 0x0e, 0x5b, 0x90, 0xd5, 0x89, 0x8c, 0x6b, 0x63, 0x24, 0x1a, 0x16, 0xbf, - 0x74, 0x33, 0x31, 0x6a, 0xc3, 0xce, 0x2c, 0xec, 0x4e, 0xad, 0x0b, 0x5d, 0x87, 0xe3, 0x96, 0x47, - 0x98, 0xdc, 0xee, 0x8b, 0x96, 0x67, 0x8f, 0x61, 0x27, 0x6f, 0x66, 0x82, 0x04, 0x52, 0x12, 0xb8, - 0x09, 0xa2, 0x05, 0xba,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 0xda, 0xa7, 0x91, 0x8d, 0xf6, 0x69, 0x60, 0x19, - 0xf4, 0xce, 0xa5, 0x2b, 0xc8, 0x7c, 0x4f, 0x10, 0x8d, 0x98, 0xb7, 0xf3, 0x7a, 0xe4, 0x7b, 0x82, - 0xe8, 0xec, 0xef, 0x04, 0x06, 0x53, 0x67, 0x73, 0xe5, 0xe9, 0x87, 0xa0, 0xdd, 0xd2, 0xd1, 0xd8, - 0x35, 0x80, 0x23, 0x32, 0x29, 0xa2, 0xbb, 0xe9, 0x84, 0xac, 0x61, 0x98, 0x31, 0x67, 0x44, 0x63, - 0x54, 0xe4, 0x5d, 0x9c, 0xb5, 0x9a, 0x61, 0x87, 0xb0, 0xfb, 0xea, 0xa6, 0xf7, 0xf1, 0x77, 0x63, - 0x13, 0xc6, 0x32, 0xfd, 0xa0, 0xdc, 0x52, 0x37, 0xe7, 0x7c, 0x28, 0x5a, 0x1e, 0xdf, 0x7b, 0x85, - 0x17, 0x6d, 0x50, 0x5f, 0x34, 0xa4, 0x11, 0xc3, 0x75, 0xce, 0x87, 0x35, 0xf6, 0x36, 0xde, 0xc9, - 0x9f, 0xe2, 0x9d, 0xac, 0x2f, 0x74, 0xc3, 0xce, 0xb6, 0x69, 0x72, 0x9e, 0xfd, 0x13, 0x00, 0x00, - 0xff, 0xff, 0xb9, 0xd4, 0x30, 0xfc, 0xa7, 0x09, 0x00, 0x00, + // 1056 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x56, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xd6, 0x3a, 0x71, 0x6c, 0xcf, 0x36, 0x8d, 0x33, 0x0a, 0xd5, 0x2a, 0x42, 0x28, 0x5a, 0x28, + 0x8a, 0x40, 0xca, 0x85, 0x2b, 0x51, 0x40, 0xaa, 0x44, 0xa1, 0x51, 0x65, 0x09, 0x12, 0x6b, 0x4d, + 0x41, 0x5c, 0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3, 0xcf, + 0x42, 0x7b, 0xc1, 0xbd, 0xb1, 0x5b, 0x00, 0xd6, 0x67, 0x5c, 0xf8, 0x70, 0x2d, 0x05, 0xd6, 0x20, + 0x4d, 0x5f, 0x4f, 0xa4, 0x21, 0x2b, 0x8c, 0xce, 0xef, 0xa1, 0x63, 0xe8, 0x29, 0x39, 0x78, 0x79, + 0x37, 0x7a, 0xff, 0x2b, 0xb2, 0x0d, 0x43, 0x59, 0x7f, 0xe4, 0x6a, 0x25, 0x9a, 0xa7, 0xde, 0x96, + 0xb5, 0xe1, 0xc1, 0xdf, 0x4b, 0x78, 0xed, 0x7a, 0xee, 0xb5, 0x03, 0x1a, 0x30, 0x38, 0xf5, 0x76, + 0x4b, 0x11, 0x3b, 0xf7, 0x6f, 0xe8, 0xcf, 0xfe, 0x0d, 0x75, 0xaf, 0x77, 0xc3, 0xce, 0xf6, 0x70, + 0xab, 0x9e, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xea, 0xac, 0x61, 0xc3, 0x09, 0x00, 0x00, } diff --git a/api/descriptions.proto b/api/descriptions.proto index 2ecde84e..3f3e99db 100644 --- a/api/descriptions.proto +++ b/api/descriptions.proto @@ -88,6 +88,7 @@ message VolumeOption { string keyring = 3; int32 bytesPerSec = 4; int32 iops = 5; + bool daxBlock = 6; } message UserGroupInfo { diff --git a/hack/update-generated-proto.sh b/hack/update-generated-proto.sh index 3b22b26f..40b84c13 100755 --- a/hack/update-generated-proto.sh +++ b/hack/update-generated-proto.sh @@ -3,7 +3,7 @@ set -o errexit set -o nounset set -o pipefail -if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3.0."* ]]; then +if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; then echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and" echo "install the platform appropriate Protobuf package for your OS: " echo diff --git a/hypervisor/context.go b/hypervisor/context.go index 45ddd24a..12f92fb2 100644 --- a/hypervisor/context.go +++ b/hypervisor/context.go @@ -18,6 +18,7 @@ import ( type VmHwStatus struct { PciAddr int //next available pci addr for pci hotplug ScsiId int //next available scsi id for scsi hotplug + PmemId int //next available pmem id for nvdimm hotplug AttachId uint64 //next available attachId for attached tty GuestCid uint32 //vsock guest cid } @@ -48,6 +49,7 @@ type VmContext struct { pciAddr int //next available pci addr for pci hotplug scsiId int //next available scsi id for scsi hotplug + pmemId int //next available pmem id for nvdimm hotplug // InterfaceCount int @@ -187,6 +189,14 @@ func (ctx *VmContext) unsetTimeout() { } } +func (ctx *VmContext) nextPmemId() int { + ctx.idLock.Lock() + id := ctx.pmemId + ctx.pmemId++ + ctx.idLock.Unlock() + return id +} + func (ctx *VmContext) nextScsiId() int { ctx.idLock.Lock() id := ctx.scsiId diff --git a/hypervisor/disk.go b/hypervisor/disk.go index d1ad7b4d..d809450b 100644 --- a/hypervisor/disk.go +++ b/hypervisor/disk.go @@ -20,6 +20,8 @@ type DiskDescriptor struct { DockerVolume bool ReadOnly bool Options map[string]string + Dax bool + PmemId int } func (d *DiskDescriptor) IsDir() bool { @@ -67,6 +69,8 @@ func NewDiskContext(ctx *VmContext, vol *api.VolumeDescription) *DiskContext { "bytespersec": strconv.Itoa(int(vol.Options.BytesPerSec)), "iops": strconv.Itoa(int(vol.Options.Iops)), } + } else if vol.Options != nil && vol.Options.DaxBlock { + dc.DiskDescriptor.Dax = true } return dc } @@ -80,7 +84,11 @@ func (dc *DiskContext) insert(result chan api.Result) { return } - dc.ScsiId = dc.sandbox.nextScsiId() + if dc.Dax { + dc.PmemId = dc.sandbox.nextPmemId() + } else { + dc.ScsiId = dc.sandbox.nextScsiId() + } usage := "volume" if dc.isRootVol { usage = "image" diff --git a/hypervisor/libvirt/libvirt.go b/hypervisor/libvirt/libvirt.go index 302229a7..843d0530 100644 --- a/hypervisor/libvirt/libvirt.go +++ b/hypervisor/libvirt/libvirt.go @@ -442,7 +442,7 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) { dom.OS.Supported = "yes" dom.OS.Type.Arch = "x86_64" - dom.OS.Type.Machine = "pc-i440fx-2.1" + dom.OS.Type.Machine = "pc-i440fx-2.1,nvdimm" dom.OS.Type.Content = "hvm" dom.SecLabel.Type = "none" @@ -917,6 +917,33 @@ func (lc *LibvirtContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, return } + if blockInfo.Dax { + // get the size + fi, e := os.Stat(blockInfo.Filename) + if e != nil { + result <- &hypervisor.DeviceFailed{} + return + } + size := fi.Size() + // compose hmp + hmp := fmt.Sprintf("object_add memory-backend-file,id=mem%d,share=on,mem-path=%s,size=%d", blockInfo.PmemId, blockInfo.Filename, size) + err := exec.Command("virsh", "-c", LibvirtdAddress, "qemu-monitor-command", ctx.Id, "--hmp", hmp).Run() + if err != nil { + result <- &hypervisor.DeviceFailed{} + return + } + hmp = fmt.Sprintf("device_add nvdimm,id=nvdimm%d,memdev=mem%d", blockInfo.PmemId, blockInfo.PmemId) + err = exec.Command("virsh", "-c", LibvirtdAddress, "qemu-monitor-command", ctx.Id, "--hmp", hmp).Run() + if err != nil { + result <- &hypervisor.DeviceFailed{} + return + } + result <- &hypervisor.BlockdevInsertedEvent{ + DeviceName: "pmem" + strconv.Itoa(blockInfo.PmemId), + } + return + } + secretUUID, err := lc.diskSecretUUID(blockInfo) if err != nil { glog.Error("generate disk-get-secret failed, ", err.Error()) diff --git a/hypervisor/persistence.go b/hypervisor/persistence.go index d8d491d6..7aab23a5 100644 --- a/hypervisor/persistence.go +++ b/hypervisor/persistence.go @@ -136,6 +136,7 @@ func (ctx *VmContext) dumpHwInfo() *VmHwStatus { return &VmHwStatus{ PciAddr: ctx.pciAddr, ScsiId: ctx.scsiId, + PmemId: ctx.pmemId, AttachId: ctx.hyperstart.LastStreamSeq(), GuestCid: ctx.GuestCid, } @@ -144,6 +145,7 @@ func (ctx *VmContext) dumpHwInfo() *VmHwStatus { func (ctx *VmContext) loadHwStatus(pinfo *PersistInfo) error { ctx.pciAddr = pinfo.HwStat.PciAddr ctx.scsiId = pinfo.HwStat.ScsiId + ctx.pmemId = pinfo.HwStat.PmemId ctx.GuestCid = pinfo.HwStat.GuestCid if ctx.GuestCid != 0 { if !VsockCidManager.MarkCidInuse(ctx.GuestCid) { diff --git a/hypervisor/qemu/qemu.go b/hypervisor/qemu/qemu.go index e426a57c..f20d6ef9 100644 --- a/hypervisor/qemu/qemu.go +++ b/hypervisor/qemu/qemu.go @@ -248,7 +248,63 @@ func (qc *QemuContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blo } } - newDiskAddSession(ctx, qc, filename, format, id, readonly, result) + commands := make([]*QmpCommand, 2) + devName := scsiId2Name(id) + if !blockInfo.Dax { + hmp := "drive_add dummy file=" + filename + ",if=none,id=" + "drive" + strconv.Itoa(id) + ",format=" + format + ",cache=writeback" + if readonly { + hmp += ",readonly" + } + commands[0] = &QmpCommand{ + Execute: "human-monitor-command", + Arguments: map[string]interface{}{ + "command-line": hmp, + }, + } + commands[1] = &QmpCommand{ + Execute: "device_add", + Arguments: map[string]interface{}{ + "driver": "scsi-hd", "bus": "scsi0.0", "scsi-id": strconv.Itoa(id), + "drive": "drive" + strconv.Itoa(id), "id": "scsi-disk" + strconv.Itoa(id), + }, + } + } else { + // compose qmp commands + // hmp: object_add memory-backend-file,id=mem2,share=on,mem-path=/path/to/dax.img,size=10G + // hmp: device_add nvdimm,id=nvdimm2,memdev=mem2 + hmp := "object_add memory-backend-file,id=mem" + strconv.Itoa(blockInfo.PmemId) + ",mem-path=" + filename + if readonly { + hmp += ",share=off" + } else { + hmp += ",share=on" + } + // get the size + fi, e := os.Stat(filename) + if e != nil { + result <- &hypervisor.DeviceFailed{} + return + } + hmp += ",size=" + strconv.FormatInt(fi.Size(), 10) + commands[0] = &QmpCommand{ + Execute: "human-monitor-command", + Arguments: map[string]interface{}{ + "command-line": hmp, + }, + } + commands[1] = &QmpCommand{ + Execute: "device_add", + Arguments: map[string]interface{}{ + "driver": "nvdimm", "memdev": "mem" + strconv.Itoa(blockInfo.PmemId), "id": "nvdimm" + strconv.Itoa(blockInfo.PmemId), + }, + } + devName = "pmem" + strconv.Itoa(blockInfo.PmemId) + } + qc.qmp <- &QmpSession{ + commands: commands, + respond: defaultRespond(result, &hypervisor.BlockdevInsertedEvent{ + DeviceName: devName, + }), + } } func (qc *QemuContext) RemoveDisk(ctx *hypervisor.VmContext, blockInfo *hypervisor.DiskDescriptor, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) { diff --git a/hypervisor/qemu/qemu_amd64.go b/hypervisor/qemu/qemu_amd64.go index 979b85f3..9e5f3a07 100644 --- a/hypervisor/qemu/qemu_amd64.go +++ b/hypervisor/qemu/qemu_amd64.go @@ -27,7 +27,7 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string { qc.cpus = boot.CPU var machineClass, memParams, cpuParams string - machineClass = "pc-i440fx-2.1" + machineClass = "pc-i440fx-2.1,nvdimm" memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem) // TODO set maxmem to the total memory of the system cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus) // TODO set it to the cpus of the system diff --git a/hypervisor/qemu/qmp_wrapper.go b/hypervisor/qemu/qmp_wrapper.go index 891189e9..1bc716f9 100644 --- a/hypervisor/qemu/qmp_wrapper.go +++ b/hypervisor/qemu/qmp_wrapper.go @@ -33,34 +33,6 @@ func defaultRespond(result chan<- hypervisor.VmEvent, callback hypervisor.VmEven } } -func newDiskAddSession(ctx *hypervisor.VmContext, qc *QemuContext, filename, format string, id int, readonly bool, result chan<- hypervisor.VmEvent) { - args := "drive_add dummy file=" + filename + ",if=none,id=" + "drive" + strconv.Itoa(id) + ",format=" + format + ",cache=writeback" - if readonly { - args += ",readonly" - } - commands := make([]*QmpCommand, 2) - commands[0] = &QmpCommand{ - Execute: "human-monitor-command", - Arguments: map[string]interface{}{ - "command-line": args, - }, - } - commands[1] = &QmpCommand{ - Execute: "device_add", - Arguments: map[string]interface{}{ - "driver": "scsi-hd", "bus": "scsi0.0", "scsi-id": strconv.Itoa(id), - "drive": "drive" + strconv.Itoa(id), "id": "scsi-disk" + strconv.Itoa(id), - }, - } - devName := scsiId2Name(id) - qc.qmp <- &QmpSession{ - commands: commands, - respond: defaultRespond(result, &hypervisor.BlockdevInsertedEvent{ - DeviceName: devName, - }), - } -} - func newDiskDelSession(ctx *hypervisor.VmContext, qc *QemuContext, id int, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) { commands := make([]*QmpCommand, 2) commands[1] = &QmpCommand{