Skip to content

Commit 429bf0f

Browse files
committed
Use *string for backingObjectId
BackingObjectId is an optional value which means there is a distinction between unset and empty value. The serialization process treats empty value as unset, which means it is changing the content between serialize/deserialize. Hostd differientiates between these 2 values and if it notices it changes will reject modifications when the VM is powered on, even though our intent was not to modify the content. This change uses *string value to distinguish all the states. Clients that care about this value will have to do similar changes as I made to the tests. BREAKING: Change backingObjectId from string to *string Signed-off-by: Nathan Prziborowski <prziborowski@gmail.com>
1 parent 2a3fd10 commit 429bf0f

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

object/virtual_device_list_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ var devices = VirtualDeviceList([]types.BaseVirtualDevice{
233233
VirtualDeviceBackingInfo: types.VirtualDeviceBackingInfo{},
234234
FileName: "[datastore1] foo.iso",
235235
Datastore: &types.ManagedObjectReference{Type: "Datastore", Value: "53fe43cc-75dc5110-3643-000c2918dc41"},
236-
BackingObjectId: "",
236+
BackingObjectId: types.New(""),
237237
},
238238
},
239239
Connectable: &types.VirtualDeviceConnectInfo{
@@ -262,7 +262,7 @@ var devices = VirtualDeviceList([]types.BaseVirtualDevice{
262262
VirtualDeviceBackingInfo: types.VirtualDeviceBackingInfo{},
263263
FileName: "[datastore1] bar/bar.vmdk",
264264
Datastore: &types.ManagedObjectReference{Type: "Datastore", Value: "53fe43cc-75dc5110-3643-000c2918dc41"},
265-
BackingObjectId: "3-3000-0",
265+
BackingObjectId: types.New("3-3000-0"),
266266
},
267267
DiskMode: "persistent",
268268
Split: types.NewBool(false),
@@ -277,7 +277,7 @@ var devices = VirtualDeviceList([]types.BaseVirtualDevice{
277277
VirtualDeviceBackingInfo: types.VirtualDeviceBackingInfo{},
278278
FileName: "[datastore1] ttylinux.vmdk",
279279
Datastore: &types.ManagedObjectReference{Type: "Datastore", Value: "53fe43cc-75dc5110-3643-000c2918dc41"},
280-
BackingObjectId: "3-3000-1",
280+
BackingObjectId: types.New("3-3000-1"),
281281
},
282282
DiskMode: "persistent",
283283
Split: types.NewBool(false),
@@ -335,7 +335,7 @@ var devices = VirtualDeviceList([]types.BaseVirtualDevice{
335335
VirtualDeviceBackingInfo: types.VirtualDeviceBackingInfo{},
336336
FileName: "[datastore1] bar/disk-201-0.vmdk",
337337
Datastore: &types.ManagedObjectReference{Type: "Datastore", Value: "53fe43cc-75dc5110-3643-000c2918dc41"},
338-
BackingObjectId: "3-3002-0",
338+
BackingObjectId: types.New("3-3002-0"),
339339
},
340340
DiskMode: "persistent",
341341
Split: types.NewBool(false),

vim25/types/json_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ var vmInfoObjForTests = VirtualMachineConfigInfo{
611611
},
612612
Backing: &VirtualDiskFlatVer2BackingInfo{
613613
VirtualDeviceFileBackingInfo: VirtualDeviceFileBackingInfo{
614-
BackingObjectId: "1",
614+
BackingObjectId: New("1"),
615615
FileName: "[datastore1] test/test.vmdk",
616616
Datastore: &ManagedObjectReference{
617617
Type: "Datastore",

vim25/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86215,7 +86215,7 @@ type VirtualDeviceFileBackingInfo struct {
8621586215
// Backing object's durable and unmutable identifier.
8621686216
//
8621786217
// Each backing object has a unique identifier which is not settable.
86218-
BackingObjectId string `xml:"backingObjectId,omitempty" json:"backingObjectId,omitempty"`
86218+
BackingObjectId *string `xml:"backingObjectId,omitempty" json:"backingObjectId,omitempty"`
8621986219
}
8622086220

8622186221
func init() {

0 commit comments

Comments
 (0)