resolve proper aarch64 image names
when automatically downloading fcos for the Apple M1, we needed to replace a statically defined URL with the dynamically determined one. also, it appears boolean qemu options `server` and `onwait` are not defined as `server=on` and `wait=off`. [NO TESTS NEEDED] Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
		
							parent
							
								
									4fe1ce154f
								
							
						
					
					
						commit
						b6089a5e99
					
				|  | @ -2,9 +2,9 @@ package machine | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" |  | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"net/http" | 	"net/http" | ||||||
|  | 	url2 "net/url" | ||||||
| 
 | 
 | ||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
| ) | ) | ||||||
|  | @ -14,9 +14,7 @@ const aarchBaseURL = "https://fedorapeople.org/groups/fcos-images/builds/latest/ | ||||||
| // Total hack until automation is possible.
 | // Total hack until automation is possible.
 | ||||||
| // We need a proper json file at least to automate
 | // We need a proper json file at least to automate
 | ||||||
| func getFCOSDownload() (*fcosDownloadInfo, error) { | func getFCOSDownload() (*fcosDownloadInfo, error) { | ||||||
| 
 |  | ||||||
| 	meta := Build{} | 	meta := Build{} | ||||||
| 	fmt.Println(aarchBaseURL + "meta.json") |  | ||||||
| 	resp, err := http.Get(aarchBaseURL + "meta.json") | 	resp, err := http.Get(aarchBaseURL + "meta.json") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
|  | @ -33,8 +31,18 @@ func getFCOSDownload() (*fcosDownloadInfo, error) { | ||||||
| 	if err := json.Unmarshal(body, &meta); err != nil { | 	if err := json.Unmarshal(body, &meta); err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | 	pathURL, err := url2.Parse(meta.BuildArtifacts.Qemu.Path) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	baseURL, err := url2.Parse(aarchBaseURL) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	pullURL := baseURL.ResolveReference(pathURL) | ||||||
| 	return &fcosDownloadInfo{ | 	return &fcosDownloadInfo{ | ||||||
| 		Location:  aarchBaseURL + "/" + meta.BuildArtifacts.Qemu.Path, | 		Location:  pullURL.String(), | ||||||
| 		Release:   "", | 		Release:   "", | ||||||
| 		Sha256Sum: meta.BuildArtifacts.Qemu.Sha256, | 		Sha256Sum: meta.BuildArtifacts.Qemu.Sha256, | ||||||
| 	}, nil | 	}, nil | ||||||
|  |  | ||||||
|  | @ -83,7 +83,7 @@ func NewMachine(opts machine.InitOptions) (machine.VM, error) { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	vm.QMPMonitor = monitor | 	vm.QMPMonitor = monitor | ||||||
| 	cmd = append(cmd, []string{"-qmp", monitor.Network + ":/" + monitor.Address + ",server,nowait"}...) | 	cmd = append(cmd, []string{"-qmp", monitor.Network + ":/" + monitor.Address + ",server=on,wait=off"}...) | ||||||
| 
 | 
 | ||||||
| 	// Add network
 | 	// Add network
 | ||||||
| 	cmd = append(cmd, "-nic", "user,model=virtio,hostfwd=tcp::"+strconv.Itoa(vm.Port)+"-:22") | 	cmd = append(cmd, "-nic", "user,model=virtio,hostfwd=tcp::"+strconv.Itoa(vm.Port)+"-:22") | ||||||
|  | @ -96,7 +96,7 @@ func NewMachine(opts machine.InitOptions) (machine.VM, error) { | ||||||
| 	// Add serial port for readiness
 | 	// Add serial port for readiness
 | ||||||
| 	cmd = append(cmd, []string{ | 	cmd = append(cmd, []string{ | ||||||
| 		"-device", "virtio-serial", | 		"-device", "virtio-serial", | ||||||
| 		"-chardev", "socket,path=" + virtualSocketPath + ",server,nowait,id=" + vm.Name + "_ready", | 		"-chardev", "socket,path=" + virtualSocketPath + ",server=on,wait=off,id=" + vm.Name + "_ready", | ||||||
| 		"-device", "virtserialport,chardev=" + vm.Name + "_ready" + ",name=org.fedoraproject.port.0"}...) | 		"-device", "virtserialport,chardev=" + vm.Name + "_ready" + ",name=org.fedoraproject.port.0"}...) | ||||||
| 	vm.CmdLine = cmd | 	vm.CmdLine = cmd | ||||||
| 	return vm, nil | 	return vm, nil | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue