gitee.com/leisunstar/runtime@v0.0.0-20200521203717-5cef3e7b53f9/virtcontainers/types/capabilities.go (about) 1 // Copyright (c) 2017 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package types 7 8 const ( 9 blockDeviceSupport = 1 << iota 10 blockDeviceHotplugSupport 11 multiQueueSupport 12 fsSharingSupported 13 ) 14 15 // Capabilities describe a virtcontainers hypervisor capabilities 16 // through a bit mask. 17 type Capabilities struct { 18 flags uint 19 } 20 21 // IsBlockDeviceSupported tells if an hypervisor supports block devices. 22 func (caps *Capabilities) IsBlockDeviceSupported() bool { 23 return caps.flags&blockDeviceSupport != 0 24 } 25 26 // SetBlockDeviceSupport sets the block device support capability to true. 27 func (caps *Capabilities) SetBlockDeviceSupport() { 28 caps.flags = caps.flags | blockDeviceSupport 29 } 30 31 // IsBlockDeviceHotplugSupported tells if an hypervisor supports hotplugging block devices. 32 func (caps *Capabilities) IsBlockDeviceHotplugSupported() bool { 33 return caps.flags&blockDeviceHotplugSupport != 0 34 } 35 36 // SetBlockDeviceHotplugSupport sets the block device hotplugging capability to true. 37 func (caps *Capabilities) SetBlockDeviceHotplugSupport() { 38 caps.flags |= blockDeviceHotplugSupport 39 } 40 41 // IsMultiQueueSupported tells if an hypervisor supports device multi queue support. 42 func (caps *Capabilities) IsMultiQueueSupported() bool { 43 return caps.flags&multiQueueSupport != 0 44 } 45 46 // SetMultiQueueSupport sets the device multi queue capability to true. 47 func (caps *Capabilities) SetMultiQueueSupport() { 48 caps.flags |= multiQueueSupport 49 } 50 51 // IsFsSharingSupported tells if an hypervisor supports host filesystem sharing. 52 func (caps *Capabilities) IsFsSharingSupported() bool { 53 return caps.flags&fsSharingSupported != 0 54 } 55 56 // SetFsSharingUnsupported sets the host filesystem sharing capability to true. 57 func (caps *Capabilities) SetFsSharingSupport() { 58 caps.flags |= fsSharingSupported 59 }