Skip to content

Commit

Permalink
Merge pull request kubevirt#10970 from alromeros/update-guestosinfo
Browse files Browse the repository at this point in the history
Expose serial number and bus type via GuestOsInfo
  • Loading branch information
kubevirt-bot authored Jan 24, 2024
2 parents 1e8346a + 693df1e commit 80e35d3
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 13 deletions.
2 changes: 2 additions & 0 deletions api/api-rule-violations-known.list
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ API rule violation: list_type_missing,kubevirt.io/api/core/v1,KubeVirtConfigurat
API rule violation: list_type_missing,kubevirt.io/api/core/v1,KubeVirtConfiguration,SupportedGuestAgentVersions
API rule violation: list_type_missing,kubevirt.io/api/core/v1,KubeVirtStatus,Conditions
API rule violation: list_type_missing,kubevirt.io/api/core/v1,NodePlacement,Tolerations
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystem,Disk
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemInfo,Filesystems
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceGuestAgentInfo,UserList
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceMigrationStatus,Conditions
Expand Down Expand Up @@ -253,6 +254,7 @@ API rule violation: names_match,kubevirt.io/api/core/v1,LunTarget,ReadOnly
API rule violation: names_match,kubevirt.io/api/core/v1,NetworkConfiguration,NetworkInterface
API rule violation: names_match,kubevirt.io/api/core/v1,PITTimer,Enabled
API rule violation: names_match,kubevirt.io/api/core/v1,RTCTimer,Enabled
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemDisk,BusType
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemInfo,Filesystems
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceGuestAgentInfo,GAVersion
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceGuestOSInfo,VersionID
Expand Down
2 changes: 2 additions & 0 deletions api/api-rule-violations.list
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ API rule violation: list_type_missing,kubevirt.io/api/core/v1,KubeVirtConfigurat
API rule violation: list_type_missing,kubevirt.io/api/core/v1,KubeVirtConfiguration,SupportedGuestAgentVersions
API rule violation: list_type_missing,kubevirt.io/api/core/v1,KubeVirtStatus,Conditions
API rule violation: list_type_missing,kubevirt.io/api/core/v1,NodePlacement,Tolerations
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystem,Disk
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemInfo,Filesystems
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceGuestAgentInfo,UserList
API rule violation: list_type_missing,kubevirt.io/api/core/v1,VirtualMachineInstanceMigrationStatus,Conditions
Expand Down Expand Up @@ -253,6 +254,7 @@ API rule violation: names_match,kubevirt.io/api/core/v1,LunTarget,ReadOnly
API rule violation: names_match,kubevirt.io/api/core/v1,NetworkConfiguration,NetworkInterface
API rule violation: names_match,kubevirt.io/api/core/v1,PITTimer,Enabled
API rule violation: names_match,kubevirt.io/api/core/v1,RTCTimer,Enabled
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemDisk,BusType
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemInfo,Filesystems
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceGuestAgentInfo,GAVersion
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceGuestOSInfo,VersionID
Expand Down
25 changes: 25 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -19720,6 +19720,13 @@
"totalBytes"
],
"properties": {
"disk": {
"type": "array",
"items": {
"default": {},
"$ref": "#/definitions/v1.VirtualMachineInstanceFileSystemDisk"
}
},
"diskName": {
"type": "string",
"default": ""
Expand All @@ -19744,6 +19751,24 @@
}
}
},
"v1.VirtualMachineInstanceFileSystemDisk": {
"description": "VirtualMachineInstanceFileSystemDisk represents the guest os FS disks",
"type": "object",
"required": [
"serial",
"bus-type"
],
"properties": {
"bus-type": {
"type": "string",
"default": ""
},
"serial": {
"type": "string",
"default": ""
}
}
},
"v1.VirtualMachineInstanceFileSystemInfo": {
"description": "VirtualMachineInstanceFileSystemInfo represents information regarding single guest os filesystem",
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions pkg/virt-launcher/virtwrap/agent-poller/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go_test(
embed = [":go_default_library"],
deps = [
"//pkg/virt-launcher/virtwrap/api:go_default_library",
"//staging/src/kubevirt.io/api/core/v1:go_default_library",
"//staging/src/kubevirt.io/client-go/testutils:go_default_library",
"//vendor/github.com/onsi/ginkgo/v2:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
Expand Down
12 changes: 7 additions & 5 deletions pkg/virt-launcher/virtwrap/agent-poller/agent_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ type User struct {

// Filesystem of the host
type Filesystem struct {
Name string `json:"name"`
Mountpoint string `json:"mountpoint"`
Type string `json:"type"`
UsedBytes int `json:"used-bytes,omitempty"`
TotalBytes int `json:"total-bytes,omitempty"`
Name string `json:"name"`
Mountpoint string `json:"mountpoint"`
Type string `json:"type"`
UsedBytes int `json:"used-bytes,omitempty"`
TotalBytes int `json:"total-bytes,omitempty"`
Disk []v1.VirtualMachineInstanceFileSystemDisk `json:"disk,omitempty"`
}

// AgentInfo from the guest VM serves the purpose
Expand Down Expand Up @@ -196,6 +197,7 @@ func parseFilesystem(agentReply string) ([]api.Filesystem, error) {
Type: fs.Type,
TotalBytes: fs.TotalBytes,
UsedBytes: fs.UsedBytes,
Disk: fs.Disk,
})
}

Expand Down
16 changes: 15 additions & 1 deletion pkg/virt-launcher/virtwrap/agent-poller/agent_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

v1 "kubevirt.io/api/core/v1"

"kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api"
)

Expand Down Expand Up @@ -268,7 +270,13 @@ var _ = Describe("Qemu agent poller", func() {
"mountpoint":"/",
"type":"ext",
"total-bytes":99999,
"used-bytes":33333
"used-bytes":33333,
"disk":[
{
"serial":"testserial-1234",
"bus-type":"scsi"
}
]
}
]
}`
Expand All @@ -280,6 +288,12 @@ var _ = Describe("Qemu agent poller", func() {
Type: "ext",
TotalBytes: 99999,
UsedBytes: 33333,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
Serial: "testserial-1234",
BusType: "scsi",
},
},
},
}
Expect(parseFilesystem(jsonInput)).To(Equal(expectedFilesystem))
Expand Down
6 changes: 6 additions & 0 deletions pkg/virt-launcher/virtwrap/api/deepcopy_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/virt-launcher/virtwrap/api/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type Filesystem struct {
Type string
UsedBytes int
TotalBytes int
Disk []v1.VirtualMachineInstanceFileSystemDisk
}

type User struct {
Expand Down
6 changes: 6 additions & 0 deletions pkg/virt-launcher/virtwrap/cmd-server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ var _ = Describe("Virt remote commands", func() {
FileSystemType: "EXT4",
UsedBytes: 3333,
TotalBytes: 9999,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
BusType: "scsi",
Serial: "testserial-1234",
},
},
},
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/virt-launcher/virtwrap/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,7 @@ func (l *LibvirtDomainManager) GetGuestInfo() v1.VirtualMachineInstanceGuestAgen
FileSystemType: fs.Type,
UsedBytes: fs.UsedBytes,
TotalBytes: fs.TotalBytes,
Disk: fs.Disk,
})
}

Expand Down Expand Up @@ -2073,6 +2074,7 @@ func (l *LibvirtDomainManager) GetFilesystems() []v1.VirtualMachineInstanceFileS
FileSystemType: fs.Type,
UsedBytes: fs.UsedBytes,
TotalBytes: fs.TotalBytes,
Disk: fs.Disk,
})
}

Expand Down
30 changes: 30 additions & 0 deletions pkg/virt-launcher/virtwrap/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,12 @@ var _ = Describe("Manager", func() {
Type: "fs",
UsedBytes: 0,
TotalBytes: 0,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
BusType: "scsi",
Serial: "testserial-1234",
},
},
},
})

Expand All @@ -2228,6 +2234,12 @@ var _ = Describe("Manager", func() {
FileSystemType: "fs",
UsedBytes: 0,
TotalBytes: 0,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
BusType: "scsi",
Serial: "testserial-1234",
},
},
}))
})

Expand Down Expand Up @@ -2259,6 +2271,12 @@ var _ = Describe("Manager", func() {
Type: "fs",
UsedBytes: 0,
TotalBytes: 0,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
BusType: "scsi",
Serial: "testserial-1234",
},
},
},
})

Expand All @@ -2280,6 +2298,12 @@ var _ = Describe("Manager", func() {
Type: "fs",
UsedBytes: 0,
TotalBytes: 0,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
BusType: "scsi",
Serial: "testserial-1234",
},
},
},
})

Expand Down Expand Up @@ -2320,6 +2344,12 @@ var _ = Describe("Manager", func() {
Type: "fs",
UsedBytes: 0,
TotalBytes: 0,
Disk: []v1.VirtualMachineInstanceFileSystemDisk{
{
BusType: "scsi",
Serial: "testserial-1234",
},
},
},
})

Expand Down
29 changes: 27 additions & 2 deletions staging/src/kubevirt.io/api/core/v1/deepcopy_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions staging/src/kubevirt.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2227,13 +2227,20 @@ type VirtualMachineInstanceFileSystemList struct {
Items []VirtualMachineInstanceFileSystem `json:"items"`
}

// VirtualMachineInstanceFileSystemDisk represents the guest os FS disks
type VirtualMachineInstanceFileSystemDisk struct {
Serial string `json:"serial"`
BusType string `json:"bus-type"`
}

// VirtualMachineInstanceFileSystem represents guest os disk
type VirtualMachineInstanceFileSystem struct {
DiskName string `json:"diskName"`
MountPoint string `json:"mountPoint"`
FileSystemType string `json:"fileSystemType"`
UsedBytes int `json:"usedBytes"`
TotalBytes int `json:"totalBytes"`
DiskName string `json:"diskName"`
MountPoint string `json:"mountPoint"`
FileSystemType string `json:"fileSystemType"`
UsedBytes int `json:"usedBytes"`
TotalBytes int `json:"totalBytes"`
Disk []VirtualMachineInstanceFileSystemDisk `json:"disk,omitempty"`
}

// FreezeUnfreezeTimeout represent the time unfreeze will be triggered if guest was not unfrozen by unfreeze command
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80e35d3

Please sign in to comment.