@@ -364,6 +364,44 @@ type qemu struct {
364
364
// Callers should check that the instance is running (and therefore mounted) before calling this function,
365
365
// otherwise the qmp.Connect call will fail to use the monitor socket file.
366
366
func (d * qemu ) getAgentClient () (* http.Client , error ) {
367
+ // FIXME: testing
368
+ if d .name == "win11" {
369
+ client := & http.Client {}
370
+
371
+ // The connection uses mutual authentication, so use the server's key & cert for client.
372
+ agentCert , _ , clientCert , clientKey , err := d .generateAgentCert ()
373
+ if err != nil {
374
+ return nil , err
375
+ }
376
+
377
+ // Get the TLS configuration.
378
+ tlsConfig , err := localtls .GetTLSConfigMem (clientCert , clientKey , "" , agentCert , false )
379
+ if err != nil {
380
+ return nil , err
381
+ }
382
+
383
+ client .Transport = & http.Transport {
384
+ TLSClientConfig : tlsConfig ,
385
+ DialContext : func (_ context.Context , network , addr string ) (net.Conn , error ) {
386
+ return net .Dial ("tcp" , "172.17.250.112:8443" )
387
+ },
388
+ DisableKeepAlives : true ,
389
+ ExpectContinueTimeout : time .Second * 30 ,
390
+ ResponseHeaderTimeout : time .Second * 3600 ,
391
+ TLSHandshakeTimeout : time .Second * 5 ,
392
+ }
393
+
394
+ // Setup redirect policy.
395
+ client .CheckRedirect = func (req * http.Request , via []* http.Request ) error {
396
+ // Replicate the headers.
397
+ req .Header = via [len (via )- 1 ].Header
398
+
399
+ return nil
400
+ }
401
+
402
+ return client , nil
403
+ }
404
+
367
405
// Check if the agent is running.
368
406
monitor , err := qmp .Connect (d .monitorPath (), qemuSerialChardevName , d .getMonitorEventHandler (), d .QMPLogFilePath ())
369
407
if err != nil {
0 commit comments