-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added NetworkDeviceAttachmentWasDisconnected api #169
Conversation
Oh I got this message in CI. Let me check... https://github.com/Code-Hex/vz/actions/runs/11648909986/job/32435851386?pr=169 It was an error that didn't seem to help. I don't know how to be helpful with regard to VZNetworkDevice.
Edit: |
d49cd9f
to
8e9c1ff
Compare
I'm sorry I changed this PR to draft to implement Go API 🙏 memo
|
a7c6705
to
9f38783
Compare
The code fell into an infinite loop, as shown in the following log, when it was committed. https://github.com/Code-Hex/vz/actions/runs/11651049051/job/32445661567
From these observations, we can deduce the following points:
Based on these points, I would like to establish the following implementation plan:
|
I could finally observe an error. @AkihiroSuda or @balajiv113 Could you review this PR? 🙏
|
if err == nil { | ||
go func() { | ||
for disconnected := range disconnected { | ||
log.Println(disconnected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
observed by this line
#169 (comment)
nsArray := objc.NewNSArray( | ||
C.networkDevicesVZVirtualMachineConfiguration(objc.Ptr(v)), | ||
) | ||
ptrs := nsArray.ToPointerSlice() | ||
networkDevices := make([]*VirtioNetworkDeviceConfiguration, len(ptrs)) | ||
for i, ptr := range ptrs { | ||
networkDevices[i] = newVirtioNetworkDeviceConfiguration(ptr) | ||
} | ||
return networkDevices | ||
return v.networkDeviceConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to take this concise approach because it is difficult to identify the interface NetworkDeviceAttachment class in the Objective-C world and restore it in the Go world.
This also has the advantage that it is identical to the VirtioNetworkDeviceConfiguration pointer at set time.
internal/sliceutil/sliceutil.go
Outdated
// FindValueByIndex returns the value of the index in s, | ||
// or -1 if not present. | ||
func FindValueByIndex[S ~[]E, E any](s S, idx int) (v E) { | ||
for i := range s { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for loop really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I will remove it.
Thank you
internal/sliceutil/sliceutil.go
Outdated
@@ -3,10 +3,8 @@ package sliceutil | |||
// FindValueByIndex returns the value of the index in s, | |||
// or -1 if not present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem returning -1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I fixed 4be99b6
ad740ac
to
4be99b6
Compare
I need to fix flaky test... |
Which issue(s) this PR fixes:
Related #118
Additional documentation
This Pull Request adds support for
attachmentWasDisconnectedWithError
only on the Objective-C side. The reason it’s not provided as a Go API is that I couldn’t reproduce the invocation of this method in my environment, so I couldn’t determine the appropriate way to expose it as a Go API.Things I tried (building
example/macOS
):VZNetworkDevice
and its attachment after the VM startedvz.NewFileHandleNetworkDeviceAttachment
after the VM startedattachmentWasDisconnectedWithError
was not executedBased on these findings, I decided to log the error content as an
NSLog
in Objective-C for now and have users report it if it occurs.You can see log like below: